Example #1
0
		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);
				}
			}
		}
Example #2
0
		public void UserLinqInsert()
		{
			using (var db = new TestDbManager("Oracle"))
			{
				db.BeginTransaction();
				db.GetTable<User>().Insert(() => new User { Name = "user" });
			}
		}
Example #3
0
		public void UserLinqInsert([IncludeDataContexts("Oracle")] string context)
		{
			using (var db = new TestDbManager(context))
			{
				db.BeginTransaction();
				db.GetTable<User>().Insert(() => new User { Name = "user" });
			}
		}
Example #4
0
		public void UserInsertWithIdentity([IncludeDataContexts("Oracle")] string context)
		{
			using (var db = new TestDbManager(context))
			{
				db.BeginTransaction();
				db.InsertWithIdentity(new User { Name = "user" });
			}
		}
Example #5
0
		public void UserInsertWithIdentity()
		{
			using (var db = new TestDbManager("Oracle"))
			{
				db.BeginTransaction();
				db.InsertWithIdentity(new User { Name = "user" });
			}
		}
Example #6
0
 public void UserInsertWithIdentity()
 {
     using (var db = new TestDbManager("Oracle"))
     {
         db.BeginTransaction();
         db.InsertWithIdentity(new User {
             Name = "user"
         });
     }
 }
Example #7
0
 public void UserLinqInsert([IncludeDataContexts("Oracle")] string context)
 {
     using (var db = new TestDbManager(context))
     {
         db.BeginTransaction();
         db.GetTable <User>().Insert(() => new User {
             Name = "user"
         });
     }
 }
Example #8
0
 public void UserLinqInsert()
 {
     using (var db = new TestDbManager("Oracle"))
     {
         db.BeginTransaction();
         db.GetTable <User>().Insert(() => new User {
             Name = "user"
         });
     }
 }
Example #9
0
 public void UserInsertWithIdentity([IncludeDataContexts("Oracle")] string context)
 {
     using (var db = new TestDbManager(context))
     {
         db.BeginTransaction();
         db.InsertWithIdentity(new User {
             Name = "user"
         });
     }
 }
Example #10
0
 public void MyType3()
 {
     using (var db = new TestDbManager {
         MappingSchema = _myMappingSchema
     })
     {
         db.BeginTransaction();
         db.Insert(new MyParent {
             ParentID = new MyInt {
                 MyValue = 1001
             }, Value1 = 1001
         });
     }
 }
Example #11
0
        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));
            }
        }
Example #12
0
		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));
			}
		}
Example #13
0
        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"
                });
            }
        }
Example #14
0
        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"
                });
            }
        }
Example #15
0
		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);
			}
		}
Example #16
0
		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" });
			}
		}
Example #17
0
		//[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"
				});
			}
		}
Example #18
0
		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" });
			}
		}
Example #19
0
		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);
				}
			}
		}
Example #20
0
		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);
			}
		}
Example #21
0
		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);
				}
			}
		}