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


C# TestDataConnection类代码示例

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


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

示例1: 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

示例2: 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

示例3: CompiledUpdate

 public void CompiledUpdate()
 {
     using (var ctx = new TestDataConnection())
     {
         _updateQuery(ctx, 12345, "54321");
     }
 }
开发者ID:henleygao,项目名称:linq2db,代码行数:7,代码来源:UpdateTest.cs

示例4: MergeWithDeletePredicate2

		public void MergeWithDeletePredicate2(string context)
		{
			using (var db = new TestDataConnection(context))
			{
				db.Merge(db.Types2, t => t.ID > 5);
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:7,代码来源:MergeTest.cs

示例5: 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

示例6: MergeWithEmptySource

		public void MergeWithEmptySource(string context)
		{
			using (var db = new TestDataConnection(context))
			{
				db.Merge(new Person[] {});
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:7,代码来源:MergeTest.cs

示例7: ContainsJoin1

        public void ContainsJoin1(string context)
        {
            using (var db = new TestDataConnection(context))
            {
                db.Child. Delete(c => c.ParentID >= 1000);
                db.Parent.Delete(c => c.ParentID >= 1000);

                try
                {
                    var id = 1000;

                    db.Insert(new Parent { ParentID = id });

                    for (var i = 0; i < 3; i++)
                        db.Insert(new Child { ParentID = id, ChildID = 1000 + i });

                    var sql1 = ContainsJoin1Impl(db, new [] { 1000, 1001 });
                    var sql2 = ContainsJoin1Impl(db, new [] { 1002       });

                    Assert.That(sql1, Is.Not.EqualTo(sql2));
                }
                finally
                {
                    db.Child. Delete(c => c.ParentID >= 1000);
                    db.Parent.Delete(c => c.ParentID >= 1000);
                }
            }
        }
开发者ID:pebezo,项目名称:linq2db,代码行数:28,代码来源:DeleteTest.cs

示例8: Merge

 public void Merge(string context)
 {
     using (var db = new TestDataConnection(context))
     {
         db.Merge(db.Types2);
     }
 }
开发者ID:jkshan,项目名称:linq2db,代码行数:7,代码来源:MergeTest.cs

示例9: CompiledFunc2

 public void CompiledFunc2([IncludeDataContexts(ProviderName.SqlServer2008)] string context)
 {
     using (var db = new TestDataConnection(context))
     {
         var q = _f2(db, 1);
         q.ToList();
     }
 }
开发者ID:henleygao,项目名称:linq2db,代码行数:8,代码来源:TableFunctionTest.cs

示例10: MergeWithDeletePredicate3

		public void MergeWithDeletePredicate3(string context)
		{
			using (var db = new TestDataConnection(context))
			{
				var patient = db.Patient.First();
				db.Merge(db.Person, t => t.Patient == patient);
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:8,代码来源:MergeTest.cs

示例11: CompiledFunc2

 public void CompiledFunc2(string context)
 {
     using (var db = new TestDataConnection(context))
     {
         var q = _f2(db, 1);
         q.ToList();
     }
 }
开发者ID:ru-sh,项目名称:linq2db,代码行数:8,代码来源:TableFunctionTest.cs

示例12: TestExecute2

		public void TestExecute2(string context)
		{
			using (var conn = new TestDataConnection(context))
			{
				var sql = conn.Person.Where(p => p.ID == 1).Select(p => p.Name).Take(1).ToString().Replace("-- Access", "");

				var res = conn.SetCommand(sql).ExecuteAsync<string>().Result;

				Assert.That(res, Is.EqualTo("John"));
			}
		}
开发者ID:r0t0r-r0t0r,项目名称:linq2db,代码行数:11,代码来源:AsyncTest.cs

示例13: SubQueryCount

		public void SubQueryCount(string context)
		{
			using (var db = new TestDataConnection(context))
			{
				AreEqual(
					from p in Parent
					select Parent.Where(t => t.ParentID == p.ParentID).Count()
					,
					from p in db.Parent
					select Sql.AsSql(db.GetParentByID(p.ParentID).Count()));
			}
		}
开发者ID:ronnyek,项目名称:linq2db,代码行数:12,代码来源:CountTests.cs

示例14: 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

示例15: GeneratePredicate

		public void GeneratePredicate()
		{
			Expression<Func<Person,bool>> a = x => x.FirstName == "John";
			Expression<Func<Person,bool>> b = x => x.LastName  == "Pupkin";

			var bBody     = b.GetBody(a.Parameters[0]);
			var predicate = Expression.Lambda<Func<Person,bool>>(Expression.AndAlso(a.Body, bBody), a.Parameters[0]);

			using (var db = new TestDataConnection())
			{
				var q = db.Person.Where(predicate);
				var p = q.First();
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:14,代码来源:GenerateTest.cs


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