当前位置: 首页>>代码示例>>C#>>正文


C# TestDataConnection.GetTable方法代码示例

本文整理汇总了C#中TestDataConnection.GetTable方法的典型用法代码示例。如果您正苦于以下问题:C# TestDataConnection.GetTable方法的具体用法?C# TestDataConnection.GetTable怎么用?C# TestDataConnection.GetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestDataConnection的用法示例。


在下文中一共展示了TestDataConnection.GetTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test

        public void Test()
        {
            using (var db = new TestDataConnection())
            {
                var q = (
                    from t1 in db.GetTable<Table1>()
                    where t1.Field3 != null
                    select new
                    {
                        t1.Ref1.Ref4.Field6, t1.Ref3.Field4,
                        Field1 = t1.Ref2.Ref5.Field8 ?? string.Empty
                    }
                ).Distinct();

                var sql1 = q.ToString();

                var q2 =
                    from t3 in q
                    group t3 by new { t3.Field6, t3.Field4 }
                    into g
                    where g.Count() > 1
                    select new { g.Key.Field6, EngineeringCircuitNumber = g.Key.Field4, Count = g.Count() };

                var sql2 = q2.ToString();

                var idx = sql2.IndexOf("DISTINCT");

                Assert.That(idx, Is.GreaterThanOrEqualTo(0));

                idx = sql2.IndexOf("Field8", idx);

                Assert.That(idx, Is.GreaterThanOrEqualTo(0));
            }
        }
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:34,代码来源:GroupBySubqueryTests.cs

示例2: Test

		public void Test()
		{
			using (var db = new TestDataConnection())
			{
				/*
				var query =
					from t3 in db.Parent
					//let t1 = t3.Children.SelectMany(x => x.GrandChildren)
					//let t2 = t3.Table2s.SelectMany(x => x.Table1s)
					select new
					{
						//c2 = t1.Count(),
						c1 = t3.Children.SelectMany(x => x.GrandChildren),
					};
				*/

				var query =
					from t3 in db.GetTable<Table3>()
					let t1 = t3.Children.SelectMany(x => x.GrandChildren)
					//let t2 = t3.Children.SelectMany(x => x.GrandChildren)
					select new
					{
						c2 = t1.Count(),
						c1 = t3.Children.SelectMany(x => x.GrandChildren).Count(),
					};

				query.FirstOrDefault(p => p.c2 > 1);
				query.FirstOrDefault();
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:30,代码来源:FirstOrDefaultNullReferenceExceptionTest.cs

示例3: AliasTest1

		public void AliasTest1()
		{
			using (var db = new TestDataConnection())
			{
				var count = db.GetTable<TestParent>().Count(t => t.ID > 0);
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:7,代码来源:ColumnAliasTest.cs

示例4: MergeChar1

        public void MergeChar1(string context)
        {
            using (var db = new TestDataConnection(context))
            {
                var id = ConvertTo<int>.From(db.GetTable<AllType>().InsertWithIdentity(() => new AllType
                {
                    charDataType  = '\x0',
                    ncharDataType = "\x0"
                }));

                try
                {
                    db.Merge(db.GetTable<AllType>().Where(t => t.ID == id));
                }
                finally
                {
                    db.GetTable<AllType>().Delete(t => t.ID == id);
                }
            }
        }
开发者ID:jkshan,项目名称:linq2db,代码行数:20,代码来源:MergeTest.cs

示例5: AliasTest2

		public void AliasTest2()
		{
			using (var db = new TestDataConnection())
			{
				db.GetTable<TestParent>()
					.Where(t => t.ID < 0 && t.ID > 0)
					.Update(t => new TestParent
					{
						ID = t.ID - 1
					});
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:12,代码来源:ColumnAliasTest.cs

示例6: IsDbGeneratedTest

        public void IsDbGeneratedTest()
        {
            using (var db = new TestDataConnection())
            {
                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));
            }
        }
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:16,代码来源:L2SAttributeTests.cs

示例7: Test

		public void Test()
		{
			using (var db = new TestDataConnection())
			{
				var q = db.GetTable<CustomTableColumn>()
					.Select(
						x => new
						{
							DataType = Sql.AsSql(ColumnDataType.Unknown),
						});

				var sql = q.ToString();

				Assert.That(sql, Is.Not.Contains("Unknown"));
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:16,代码来源:UnknownSqlTest.cs

示例8: LetTest2

        public void LetTest2()
        {
            using (var repository = new TestDataConnection())
            {
                var q =
                    from t1 in repository.GetTable<Table2>()
                    from t2 in
                        from t5 in t1.Ref3.Ref4.Ref1.Ref2
                        let  t3 = t1.Ref3
                        where t3.Ref5 == t5.Ref5
                        from t4 in t5.Ref9
                        select t4
                    select t1;

                var linqResult = q.ToString();
            }
        }
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:17,代码来源:LetTests.cs

示例9: MergeChar2

 public void MergeChar2(string context)
 {
     using (var db = new TestDataConnection(context))
     {
         try
         {
             db.Merge(new[]
             {
                 new AllType
                 {
                     ID            = 10,
                     charDataType  = '\x0',
                     ncharDataType = "\x0"
                 }
             });
         }
         finally
         {
             db.GetTable<AllType>().Delete(t => t.ID == 10);
         }
     }
 }
开发者ID:jkshan,项目名称:linq2db,代码行数:22,代码来源:MergeTest.cs

示例10: TestMethod

		public void TestMethod()
		{
			using (var db = new TestDataConnection())
			{
				IQueryable<IDocument> query = db.GetTable<Document>();
				var idsQuery = query.Select(s => s.Id);
				var str = idsQuery.ToString(); // Exception
				Assert.IsNotNull(str);
			}
		}
开发者ID:pebezo,项目名称:linq2db,代码行数:10,代码来源:Mapping.cs

示例11: MyType2

		public void MyType2()
		{
			using (var db = new TestDataConnection().AddMappingSchema(_myMappingSchema))
			{
				var list = db.GetTable<MyParent>()
					.Select(t => new MyParent { ParentID = t.ParentID, Value1 = t.Value1 })
					.ToList();
			}
		}
开发者ID:pebezo,项目名称:linq2db,代码行数:9,代码来源:Mapping.cs

示例12: MyType1

		public void MyType1()
		{
			using (var db = new TestDataConnection().AddMappingSchema(_myMappingSchema))
			{
				var list = db.GetTable<MyParent>().ToList();
			}
		}
开发者ID:pebezo,项目名称:linq2db,代码行数:7,代码来源:Mapping.cs

示例13: People2

 public ITable<Person> People2(TestDataConnection db)
 {
     return db.GetTable<Person>();
 }
开发者ID:ili,项目名称:linq2db,代码行数:4,代码来源:CommonTests.cs

示例14: Concat90

        public void Concat90()
        {
            using(var context = new TestDataConnection())
            {
                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);
            }
        }
开发者ID:henleygao,项目名称:linq2db,代码行数:33,代码来源:ConcatUnionTest.cs

示例15: MyType5

		public void MyType5()
		{
			using (var db = new TestDataConnection().AddMappingSchema(_myMappingSchema) as TestDataConnection)
			{
				try
				{
					db.GetTable<MyParent>().Insert(() => new MyParent { ParentID = new MyInt { MyValue = 1001 }, Value1 = 1001 });
				}
				finally
				{
					db.Parent.Delete(p => p.ParentID >= 1000);
				}
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:14,代码来源:Mapping.cs


注:本文中的TestDataConnection.GetTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。