protected override ICommandFactory CreateFactory() { SqlConnection conn = new SqlConnection("Data Source=ANKARA;Initial Catalog=PERSONELKOSGEB;User ID=sa;Password=1"); conn.Open(); DbAccess dataAccess = new DbAccess(conn); dataAccess.ExecuteSqlComplete += (e) => { using (Stream fs = new FileStream("C:\\sql.txt", FileMode.Append, FileAccess.Write)) { using (StreamWriter sw = new StreamWriter(fs)) { if (e.Query != null) { sw.WriteLine(e.Query.Text.ToString()); sw.WriteLine(); sw.WriteLine(); sw.WriteLine(e.Query.ToParameterlessQuery()); sw.WriteLine(); // sw.WriteLine(); } } } }; AppX.Data.SqlServer.CommandFactory ret = new CommandFactory(dataAccess); return ret; }
private static void Batch_Update_Identity() { ICommandFactory factory = new CommandFactory(Helper.DataAccess); IEnumerable<SICIL> list = Helper.Factory.CreateSelectCommand().Select<SICIL>(new EntityMetaDataProviderEF4(typeof(SICIL)), null); list = list.Take(100); IBatchCommandUpdate cmd = (IBatchCommandUpdate)factory.CreateBatchCommand(BatchCommandType.Update); cmd.UpdatedFields = new HashSet<string>() { "ADI" }; Console.WriteLine(cmd.Update(list, BatchCommandMode.Batch)); Console.WriteLine(cmd.Update(list, BatchCommandMode.Single)); //Console.WriteLine(factory.CreateBatchCommand(BatchCommandType.Update).Execute(list, BatchCommandMode.Batch)); // Console.WriteLine(factory.CreateBatchCommand(BatchCommandType.Update).Execute(list, BatchCommandMode.Single)); }