public void Transaction() { foreach (var provider in Providers) { using (var db = new TestDbManager(provider.Name)) { var list = new[] { new Parent { ParentID = 1111, Value1 = 1111 }, new Parent { ParentID = 2111, Value1 = 2111 }, new Parent { ParentID = 3111, Value1 = 3111 }, new Parent { ParentID = 4111, Value1 = 4111 }, }; foreach (var parent in list) db.Parent.Delete(p => p.ParentID == parent.ParentID); db.BeginTransaction(); db.InsertBatch(list); db.CommitTransaction(); foreach (var parent in list) db.Parent.Delete(p => p.ParentID == parent.ParentID); } } }
public void UserLinqInsert() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); db.GetTable<User>().Insert(() => new User { Name = "user" }); } }
public void UserLinqInsert([IncludeDataContexts("Oracle")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); db.GetTable<User>().Insert(() => new User { Name = "user" }); } }
public void UserInsertWithIdentity([IncludeDataContexts("Oracle")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); db.InsertWithIdentity(new User { Name = "user" }); } }
public void UserInsertWithIdentity() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); db.InsertWithIdentity(new User { Name = "user" }); } }
public void UserInsertWithIdentity() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); db.InsertWithIdentity(new User { Name = "user" }); } }
public void UserLinqInsert([IncludeDataContexts("Oracle")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); db.GetTable <User>().Insert(() => new User { Name = "user" }); } }
public void UserLinqInsert() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); db.GetTable <User>().Insert(() => new User { Name = "user" }); } }
public void UserInsertWithIdentity([IncludeDataContexts("Oracle")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); db.InsertWithIdentity(new User { Name = "user" }); } }
public void MyType3() { using (var db = new TestDbManager { MappingSchema = _myMappingSchema }) { db.BeginTransaction(); db.Insert(new MyParent { ParentID = new MyInt { MyValue = 1001 }, Value1 = 1001 }); } }
public void IsDbGeneratedTest() { using (var db = new TestDbManager("Sql2008")) { db.BeginTransaction(); var id = db.InsertWithIdentity(new L2SPersons { FirstName = "Test", LastName = "Test", Gender = "M" }); db.GetTable <L2SPersons>().Delete(p => p.PersonID == ConvertTo <int> .From(id)); } }
public void IsDbGeneratedTest() { using (var db = new TestDbManager("Sql2008")) { db.BeginTransaction(); var id = db.InsertWithIdentity(new L2SPersons { FirstName = "Test", LastName = "Test", Gender = "M" }); db.GetTable<L2SPersons>().Delete(p => p.PersonID == ConvertTo<int>.From(id)); } }
public void ContractLinqManyInsert([IncludeDataContexts("Oracle")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.GetTable <User>().Insert(db.GetTable <Contract>(), x => new Contract { UserId = x.Id, ContractNo = 1, Name = "contract" }); } }
public void ContractLinqInsertWithIdentity() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.GetTable <Contract>().InsertWithIdentity(() => new Contract { UserId = user.Id, ContractNo = 1, Name = "contract" }); } }
public void Transaction([DataContexts(ExcludeLinqService = true)] string context, [Values(Int32.MaxValue, 1)]int batchSize) { using (var db = new TestDbManager(context)) { var list = new[] { new Parent { ParentID = 1111, Value1 = 1111 }, new Parent { ParentID = 2111, Value1 = 2111 }, new Parent { ParentID = 3111, Value1 = 3111 }, new Parent { ParentID = 4111, Value1 = 4111 }, }; foreach (var parent in list) db.Parent.Delete(p => p.ParentID == parent.ParentID); db.BeginTransaction(); db.InsertBatch(batchSize, list); db.CommitTransaction(); foreach (var parent in list) db.Parent.Delete(p => p.ParentID == parent.ParentID); } }
public void ContractLinqInsertWithIdentity([IncludeDataContexts("Oracle")] string context) { using (var db = new TestDbManager(context)) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.GetTable<Contract>().InsertWithIdentity(() => new Contract { UserId = user.Id, ContractNo = 1, Name = "contract" }); } }
//[Test] public void ContractLinqManyInsertWithIdentity() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.GetTable<User>().InsertWithIdentity(db.GetTable<Contract>(), x => new Contract { UserId = x.Id, ContractNo = 1, Name = "contract" }); } }
public void ContractInsert() { using (var db = new TestDbManager("Oracle")) { db.BeginTransaction(); var user = new User { Name = "user" }; user.Id = Convert.ToInt64(db.InsertWithIdentity(user)); db.Insert(new Contract { UserId = user.Id, ContractNo = 1, Name = "contract1" }); } }
public void TransactionWithIdentity1([DataContexts(ExcludeLinqService = true)] string context) { using (var db = new TestDbManager(context)) { try { var list = new[] { new Table {IntValue = 1111, StringValue = "1111"}, new Table {IntValue = 2111, StringValue = "2111"}, new Table {IntValue = 3111, StringValue = "3111"}, new Table {IntValue = 4111, StringValue = "4111"}, }; db.GetTable<Table>().Delete(_ => _.Id > 2); var c1 = db.GetTable<Table>().Count(); db.BeginTransaction(); db.InsertBatch(list); db.CommitTransaction(); var c2 = db.GetTable<Table>().Count(); Assert.AreEqual(c1+4, c2); } finally { db.GetTable<Table>().Delete(_ => _.Id > 2); } } }
public void MyType3() { using (var db = new TestDbManager { MappingSchema = _myMappingSchema }) { db.BeginTransaction(); db.Insert(new MyParent { ParentID = new MyInt { MyValue = 1001 }, Value1 = 1001 }); db.Parent.Delete(p => p.ParentID >= 1000); } }
public void TransactionWithIdentity2([DataContexts(ExcludeLinqService = true)] string context) { using (var db = new TestDbManager(context)) { try { var list = new[] { new Table2 {IntValue = 1111, Object = new TestObject{Value = 1111}}, new Table2 {IntValue = 1111, Object = new TestObject{Value = 1111}}, new Table2 {IntValue = 1111, Object = new TestObject{Value = 1111}}, new Table2 {IntValue = 1111, Object = new TestObject{Value = 1111}}, }; db.GetTable<Table2>().Delete(_ => _.IntValue == 1111); var c1 = db.GetTable<Table2>().Count(); db.BeginTransaction(); db.InsertBatch(list); db.CommitTransaction(); var c2 = db.GetTable<Table2>().Count(); Assert.AreEqual(c1+4, c2); var result = db.GetTable<Table2>().Where(_ => _.IntValue == 1111).ToList(); foreach (var e in result) { Assert.AreEqual(1111, e.Object.Value); } } finally { db.GetTable<Table2>().Delete(_ => _.IntValue == 1111); } } }