Example #1
0
        public void Concat90()
        {
            using (var context = new TestDbManager())
            {
                var join1 =
                    from t1 in context.GetTable <TestEntity1>()
                    join t2 in context.GetTable <TestEntity2>()
                    on t1.Id equals t2.Id
                    into tmp
                    from t2 in tmp.DefaultIfEmpty()
                    select new { t1, t2 };

                var join1Sql = join1.ToString();
                Assert.IsNotNull(join1Sql);

                var join2 =
                    from t2 in context.GetTable <TestEntity2>()
                    join t1 in context.GetTable <TestEntity1>()
                    on t2.Id equals t1.Id
                    into tmp
                    from t1 in tmp.DefaultIfEmpty()
                    where t1 == null
                    select new { t1, t2 };

                var join2Sql = join2.ToString();
                Assert.IsNotNull(join2Sql);

                var fullJoin = join1.Concat(join2);

                var fullJoinSql = fullJoin.ToString();                 // BLToolkit.Data.Linq.LinqException : Types in Concat are constructed incompatibly.
                Assert.IsNotNull(fullJoinSql);
            }
        }
Example #2
0
        //[Test]
        public void BoolTest2()
        {
            List <PersonBoolTest> list;

            using (var db = new TestDbManager())
                list = db.GetTable <PersonBoolTest>().ToList();

            ForEachProvider(db => AreEqual(
                                from p in list                          where p.IsMale == true select p.PersonID,
                                from p in db.GetTable <PersonBoolTest>() where p.IsMale == true select p.PersonID));
        }
Example #3
0
        public void CharTest2()
        {
            List <PersonCharTest> list;

            using (var db = new TestDbManager())
                list = db.GetTable <PersonCharTest>().ToList();

            ForEachProvider(db => AreEqual(
                                from p in list                          where 'M' == p.Gender select p.PersonID,
                                from p in db.GetTable <PersonCharTest>() where 'M' == p.Gender select p.PersonID));
        }
Example #4
0
        public void IEnumerableTest2()
        {
            using (var db = new TestDbManager())
            {
                var zones =
                    from z in db.GetTable <TestEntity2>()
                    join o in db.GetTable <SuperAccount>() on z.Owner.Id equals o.Id
                    select z;

                zones.ToList();
            }
        }
Example #5
0
        public void IEnumerableTest1()
        {
            using (var db = new TestDbManager())
            {
                var res =
                    from rc in db.GetTable <TestEntity>()
                    join li in db.GetTable <LookupEntity>() on rc.Id equals li.InnerEnity.Id
                    where rc.EntityType == TestEntityType.Type1
                    select rc;

                res.ToList();
            }
        }
 public void ExplicitInterface3()
 {
     using (var db = new TestDbManager())
     {
         var result = SelectNoDate2(db.GetTable <TestTable3>()).ToList();
     }
 }
Example #7
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 #8
0
 public void GuidTest()
 {
     using (var db = new TestDbManager())
     {
         var list = db.GetTable <InheritanceA>().Where(a => a.Bs.Any()).ToList();
     }
 }
Example #9
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 #10
0
		public void UserLinqInsert()
		{
			using (var db = new TestDbManager("Oracle"))
			{
				db.BeginTransaction();
				db.GetTable<User>().Insert(() => new User { Name = "user" });
			}
		}
Example #11
0
 public void MyType1()
 {
     using (var db = new TestDbManager {
         MappingSchema = _myMappingSchema
     })
     {
         var list = db.GetTable <MyParent>().ToList();
     }
 }
Example #12
0
		public void AllNames()
		{
			using (var db = new TestDbManager("Sql2008"))
				db.GetTable<ParenTable>()
					.DatabaseName("BLToolkitData")
					.OwnerName("dbo")
					.TableName("Parent")
					.ToList();
		}
Example #13
0
		public void AllNames([IncludeDataContexts("Sql2008")] string context)
		{
			using (var db = new TestDbManager(context))
				db.GetTable<ParenTable>()
					.DatabaseName("TestData")
					.OwnerName("dbo")
					.TableName("Parent")
					.ToList();
		}
Example #14
0
		public void AllNames([IncludeDataContexts("Sql2008")] string context)
		{
			using (var db = new TestDbManager(context))
				db.GetTable<ParenTable>()
					.DatabaseName("BLToolkitData")
					.OwnerName("dbo")
					.TableName("Parent")
					.ToList();
		}
Example #15
0
 public void AllNames()
 {
     using (var db = new TestDbManager("Sql2008"))
         db.GetTable <ParenTable>()
         .DatabaseName("BLToolkitData")
         .OwnerName("dbo")
         .TableName("Parent")
         .ToList();
 }
Example #16
0
 public void UserLinqInsert()
 {
     using (var db = new TestDbManager("Oracle"))
     {
         db.BeginTransaction();
         db.GetTable <User>().Insert(() => new User {
             Name = "user"
         });
     }
 }
Example #17
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 #18
0
        public void MapAbstract()
        {
            using (var db = new TestDbManager())
            {
                var q = from a in db.GetTable <AbsChild>()
                        select new { a.ChildID, a.Parent.Value1 };

                var ql = q.ToList();
            }
        }
Example #19
0
 public void TestMethod()
 {
     using (var db = new TestDbManager())
     {
         IQueryable <IDocument> query = db.GetTable <Document>();
         var idsQuery = query.Select(s => s.Id);
         var str      = idsQuery.ToString();            // Exception
         Assert.IsNotNull(str);
     }
 }
Example #20
0
        public void InheritanceMappingIssueTest()
        {
            using (var db = new TestDbManager())
            {
                var q1 = db.GetTable <Parent222>();
                var q  = q1.Where(_ => _.Value.ID == 1);

                var sql = ((Table <Parent222>)q).SqlText;
                Assert.IsNotEmpty(sql);
            }
        }
Example #21
0
 public void MyType2()
 {
     using (var db = new TestDbManager {
         MappingSchema = _myMappingSchema
     })
     {
         var list = db.GetTable <MyParent>()
                    .Select(t => new MyParent {
             ParentID = t.ParentID, Value1 = t.Value1
         })
                    .ToList();
     }
 }
Example #22
0
        public void SelectField()
        {
            using (var db = new TestDbManager())
            {
                var q =
                    from p in db.GetTable <TestParent>()
                    select p.Value1_;

                var sql = q.ToString();

                Assert.That(sql.IndexOf("ParentID_"), Is.LessThan(0));
            }
        }
Example #23
0
		public void IsDbGeneratedTest()
		{
			using (var db = new TestDbManager("Sql2008"))
			{
				var id = db.InsertWithIdentity(new L2SPersons
				{
					FirstName = "Test",
					LastName  = "Test",
					Gender    = "M"
				});

				db.GetTable<L2SPersons>().Delete(p => p.PersonID == ConvertTo<int>.From(id));
			}
		}
Example #24
0
        public void IsDbGeneratedTest()
        {
            using (var db = new TestDbManager("Sql2008"))
            {
                var id = db.InsertWithIdentity(new L2SPersons
                {
                    FirstName = "Test",
                    LastName  = "Test",
                    Gender    = "M"
                });

                db.GetTable <L2SPersons>().Delete(p => p.PersonID == ConvertTo <int> .From(id));
            }
        }
Example #25
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 #26
0
		public void IsDbGeneratedTest([IncludeDataContexts("Sql2008", "Sql2012")] string context)
		{
			using (var db = new TestDbManager(context))
			{
				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 #27
0
        public void IsDbGeneratedTest([IncludeDataContexts("Sql2008", "Sql2012")] string context)
        {
            using (var db = new TestDbManager(context))
            {
                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 #28
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 #29
0
		public void DatabaseName([IncludeDataContexts("Sql2008")] string context)
		{
			using (var db = new TestDbManager(context))
				db.GetTable<Parent>().DatabaseName("BLToolkitData").ToList();
		}
Example #30
0
		public void MapAbstract()
		{
			using (var db = new TestDbManager())
			{
				var q = from a in db.GetTable<AbsChild>()
				select new { a.ChildID, a.Parent.Value1 };

				var ql = q.ToList();
			}
		}
Example #31
0
		public void OwnerName([IncludeDataContexts("Sql2008", "Sql2012")] string context)
		{
			using (var db = new TestDbManager(context))
				db.GetTable<Parent>().OwnerName("dbo").ToList();
		}
Example #32
0
 public void OwnerName()
 {
     using (var db = new TestDbManager("Sql2008"))
         db.GetTable <Parent>().OwnerName("dbo").ToList();
 }
Example #33
0
		public void MyType1()
		{
			using (var db = new TestDbManager { MappingSchema = _myMappingSchema })
			{
				var list = db.GetTable<MyParent>().ToList();
			}
		}
Example #34
0
		public void DatabaseName([IncludeDataContexts("Sql2008")] string context)
		{
			using (var db = new TestDbManager(context))
				db.GetTable<Parent>().DatabaseName("TestData").ToList();
		}
Example #35
0
 public void TableName()
 {
     using (var db = new TestDbManager("Sql2008"))
         db.GetTable <ParenTable>().TableName("Parent").ToList();
 }
Example #36
0
		public void NoTransactionWithIdentity2([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.InsertBatch(list);
					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);
				}
			}
		}
Example #37
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 #38
0
 public void SimplTest()
 {
     using (var db = new TestDbManager())
         Assert.AreEqual(1, db.GetTable <PersonEx>().Where(_ => _.FirstName == "John").Select(_ => _.ID).Single());
 }
Example #39
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 #40
0
		public void Concat90()
		{
			using(var context = new TestDbManager())
			{
				var join1 =
					from t1 in context.GetTable<TestEntity1>()
					join t2 in context.GetTable<TestEntity2>()
						on t1.Id equals t2.Id
					into tmp
					from t2 in tmp.DefaultIfEmpty()
					select new { t1, t2 };

				var join1Sql = join1.ToString();
				Assert.IsNotNull(join1Sql);

				var join2 =
					from t2 in context.GetTable<TestEntity2>()
					join t1 in context.GetTable<TestEntity1>()
						on t2.Id equals t1.Id
					into tmp
					from t1 in tmp.DefaultIfEmpty()
					where t1 == null
					select new { t1, t2 };

				var join2Sql = join2.ToString();
				Assert.IsNotNull(join2Sql);

				var fullJoin = join1.Concat(join2);

				var fullJoinSql = fullJoin.ToString(); // BLToolkit.Data.Linq.LinqException : Types in Concat are constructed incompatibly.
				Assert.IsNotNull(fullJoinSql);
			}
		}
Example #41
0
		public void CharTest2()
		{
			List<PersonCharTest> list;

			using (var db = new TestDbManager())
				list = db.GetTable<PersonCharTest>().ToList();

			ForEachProvider(db => AreEqual(
				from p in list                          where 'M' == p.Gender select p.PersonID,
				from p in db.GetTable<PersonCharTest>() where 'M' == p.Gender select p.PersonID));
		}
Example #42
0
		public void OwnerName([IncludeDataContexts("Sql2008", "Sql2012")] string context)
		{
			using (var db = new TestDbManager(context))
				db.GetTable<Parent>().OwnerName("dbo").ToList();
		}
Example #43
0
		//[Test]
		public void BoolTest2()
		{
			List<PersonBoolTest> list;

			using (var db = new TestDbManager())
				list = db.GetTable<PersonBoolTest>().ToList();

			ForEachProvider(db => AreEqual(
				from p in list                          where p.IsMale == true select p.PersonID,
				from p in db.GetTable<PersonBoolTest>() where p.IsMale == true select p.PersonID));
		}
Example #44
0
		public void OwnerName()
		{
			using (var db = new TestDbManager("Sql2008"))
				db.GetTable<Parent>().OwnerName("dbo").ToList();
		}
Example #45
0
 public void DatabaseName()
 {
     using (var db = new TestDbManager("Sql2008"))
         db.GetTable <Parent>().DatabaseName("BLToolkitData").ToList();
 }
Example #46
0
		public void DatabaseName()
		{
			using (var db = new TestDbManager("Sql2008"))
				db.GetTable<Parent>().DatabaseName("BLToolkitData").ToList();
		}
Example #47
0
		public void InheritanceMappingIssueTest()
		{
			using (var db = new TestDbManager())
			{
				var q1 = db.GetTable<Parent222>();
				var q  = q1.Where(_ => _.Value.ID == 1);

				var sql = ((Table<Parent222>)q).SqlText;
				Assert.IsNotEmpty(sql);
			}
		}
Example #48
0
		public void TableName()
		{
			using (var db = new TestDbManager("Sql2008"))
				db.GetTable<ParenTable>().TableName("Parent").ToList();
		}
Example #49
0
		public void MyType2()
		{
			using (var db = new TestDbManager { MappingSchema = _myMappingSchema })
			{
				var list = db.GetTable<MyParent>()
					.Select(t => new MyParent { ParentID = t.ParentID, Value1 = t.Value1 })
					.ToList();
			}
		}
Example #50
0
		public void SimplTest()
		{
			using (var db = new TestDbManager())
				Assert.AreEqual(1, db.GetTable<PersonEx>().Where(_ => _.FirstName == "John").Select(_ => _.ID).Single());
		}
Example #51
0
		public void TestMethod()
		{
			using (var db = new TestDbManager())
			{
				IQueryable<IDocument> query = db.GetTable<Document>();
				var idsQuery = query.Select(s => s.Id);
				var str = idsQuery.ToString(); // Exception
				Assert.IsNotNull(str);
			}
		}
Example #52
0
		public void SelectField()
		{
			using (var db = new TestDbManager())
			{
				var q =
					from p in db.GetTable<TestParent>()
					select p.Value1_;

				var sql = q.ToString();

				Assert.That(sql.IndexOf("ParentID_"), Is.LessThan(0));
			}
		}