public static void Execute() { var connection = DbConnectionFactory.CreateTransient(); using (var context = new EntityContext(connection)) { context.EntitySimples.Add(new EntitySimple() { Name = "test1", ColumnInt = 1 }); context.EntitySimples.Add(new EntitySimple() { Name = "test2", ColumnInt = 2 }); context.BulkSaveChanges(); } using (var context = new EntityContext(connection)) { List <EntitySimple> list = new List <EntitySimple>(); list.Add(new EntitySimple() { Name = "test1", ColumnInt = 50 }); list.Add(new EntitySimple() { Name = "test3", ColumnInt = 50 }); context.BulkMerge(list); } using (var context = new EntityContext(connection)) { var list = context.EntitySimples.ToList(); } using (var context = new EntityContext(connection)) { context.EntityIndexStrings.Add(new EntityIndexString() { Name = "test1", ColumnInt = 1 }); context.EntityIndexStrings.Add(new EntityIndexString() { Name = "test2", ColumnInt = 2 }); context.BulkSaveChanges(); } using (var context = new EntityContext(connection)) { var list = context.EntityIndexStrings.Where(x => x.Name == "test1").ToList(); list.Add(new EntityIndexString() { Name = "test3", ColumnInt = 3 }); list.ForEach(x => x.ColumnInt += 200); context.BulkMerge(list); } using (var context = new EntityContext(connection)) { var list = context.EntityIndexStrings.ToList(); } }
public Form_Test_EFE() { InitializeComponent(); var connection = Effort.DbConnectionFactory.CreateTransient(); // CLEAN // SEED using (var context = new EntityContext(connection)) { context.EntitySimples.Add(new EntitySimple { ColumnInt = 1 }); context.EntitySimples.Add(new EntitySimple { ColumnInt = 2 }); context.EntitySimples.Add(new EntitySimple { ColumnInt = 34 }); context.BulkSaveChanges(); } using (var context = new EntityContext2(connection)) { context.EntitySimples.Add(new EntitySimple { ColumnInt = 1 }); context.EntitySimples.Add(new EntitySimple { ColumnInt = 22 }); context.EntitySimples.Add(new EntitySimple { ColumnInt = 3 }); context.BulkSaveChanges(); } var connection2 = Effort.DbConnectionFactory.CreateTransient(); using (var context = new EntityContext3(connection2)) { context.Database.CreateIfNotExists(); context.TestEFs.Add(new TestEF { ColumnInt = 1, B = Byte.MaxValue, binary = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 } }); context.TestEFs.Add(new TestEF { ColumnInt = 22 }); context.TestEFs.Add(new TestEF { ColumnInt = 3 }); context.BulkSaveChanges(); } // TEST using (var context = new EntityContext(connection)) { var list = context.EntitySimples.ToList(); } using (var context = new EntityContext2(connection)) { var list = context.EntitySimples.ToList(); } using (var context = new EntityContext3(connection2)) { var list = context.TestEFs.Where(x => x.B == Byte.MaxValue).ToList(); list.ForEach(x => x.B = 133); context.BulkUpdate(list); } using (var context = new EntityContext3(connection2)) { var list = context.TestEFs.Where(x => x.B == 133).ToList(); } List <TestEF> listTracking = new List <TestEF>(); using (var context = new EntityContext3(connection2)) { listTracking = context.TestEFs.ToList(); listTracking.ForEach(x => { x.B = 122; x.binary = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20 }; }); listTracking.Add(new TestEF() { B = 122, binary = new byte[] { 0x20, 0x20, 0x20, 0x20 }, ColumnInt = 555 }); context.BulkMerge(listTracking); var list = context.TestEFs.ToList(); list.ForEach(x => { x.B = 123; x.binary = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20 }; }); context.TestEFs.Remove(list.ElementAt(0)); context.TestEFs.Remove(list.ElementAt(1)); context.BulkSaveChanges(); } if (listTracking.Where(x => x.B == 123).ToList().Count != 3) { throw new Exception("ERROER"); } using (var context = new EntityContext3(connection2)) { var list = context.TestEFs.ToList(); list.ForEach(x => { x.B = 125; x.binary = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20 }; }); context.TestEFs.Remove(list.ElementAt(0)); context.BulkSaveChanges(false); } if (listTracking.Where(x => x.B == 125).ToList().Count != 3) { throw new Exception("ERROER"); } using (var context = new EntityContext3(connection2)) { var list = context.TestEFs.Where(x => x.B == 123).ToList(); var testa = context.TestEFs.Where(x => x.binary == new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20 }).ToList(); context.BulkDelete(list); } using (var context = new EntityContext3(connection2)) { var list = context.TestEFs.ToList(); } }