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


C# DataConnection.Query方法代码示例

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


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

示例1: TestScalar3

		public void TestScalar3(string context)
		{
			using (var conn = new DataConnection(context))
			{
				var list = conn.Query<DateTimeOffset>("SELECT CURRENT_TIMESTAMP").ToList();

				Assert.That(list.Count, Is.EqualTo(1));
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:9,代码来源:DataExtensionsTest.cs

示例2: TestObject1

		public void TestObject1(string context)
		{
			using (var conn = new DataConnection(context))
			{
				var list = conn.Query<QueryObject>("SELECT 1 as Column1, CURRENT_TIMESTAMP as Column2").ToList();

				Assert.That(list.Count, Is.EqualTo(1));
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:9,代码来源:DataExtensionsTest.cs

示例3: TestScalar2

		public void TestScalar2(string context)
		{
			using (var conn = new DataConnection(context))
			{
				var list = conn.Query<int>("SELECT 1").ToList();

				Assert.That(new[] { 1 }, Is.EquivalentTo(list));
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:9,代码来源:DataExtensionsTest.cs

示例4: TestScalar2

		public void TestScalar2([IncludeDataContexts(ProviderName.SqlServer)] string context)
		{
			using (var conn = new DataConnection(context))
			{
				var list = conn.Query<int>("SELECT 1").ToList();

				Assert.That(new[] { 1 }, Is.EquivalentTo(list));
			}
		}
开发者ID:henleygao,项目名称:linq2db,代码行数:9,代码来源:DataExtensionsTest.cs

示例5: Test

        public void Test([IncludeDataContexts(ProviderName.SqlServer2008)] string context)
        {
            using (var db = new DataConnection(context))
            {
                var p1 = PersonSelectByKey(db, 1).First();
                var p2 = db.Query<Person>("SELECT * FROM Person WHERE PersonID = @id", new { id = 1 }).First();

                Assert.AreEqual(p1, p2);
            }
        }
开发者ID:henleygao,项目名称:linq2db,代码行数:10,代码来源:ProcedureTest.cs

示例6: Test

		public void Test(string context)
		{
			using (var db = new DataConnection(context))
			{
				var p1 = PersonSelectByKey(db, 1).First();
				var p2 = db.Query<Person>("SELECT * FROM Person WHERE PersonID = @id", new { id = 1 }).First();

				Assert.AreEqual(p1, p2);
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:10,代码来源:ProcedureTest.cs

示例7: TestObject2

		public void TestObject2(string context)
		{
			using (var conn = new DataConnection(context))
			{
				var list = conn.Query(
					new
					{
						Column1 = 1,
						Column2 = DateTime.MinValue
					},
					"SELECT 1 as Column1, CURRENT_TIMESTAMP as Column2").ToList();

				Assert.That(list.Count, Is.EqualTo(1));
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:15,代码来源:DataExtensionsTest.cs

示例8: CacheTest

		public void CacheTest(string context)
		{
			using (var dc= new DataConnection(context))
			{
				dc.Execute("CREATE TABLE #t1(v1 int not null)");
				dc.Execute("INSERT INTO #t1(v1) values (1)");
				var v1 = dc.Query<object>("SELECT v1 FROM #t1").ToList();
				dc.Execute("ALTER TABLE #t1 ALTER COLUMN v1 INT NULL");

				DataConnection.ClearObjectReaderCache();

				dc.Execute("INSERT INTO #t1(v1) VALUES (null)");
				var v2 = dc.Query<object>("SELECT v1 FROM #t1").ToList();
			}
		}
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:15,代码来源:DataExtensionsTests.cs

示例9: TestStruct1

		public void TestStruct1([IncludeDataContexts(ProviderName.SqlServer)] string context)
		{
			using (var conn = new DataConnection(context))
			{
				var list = conn.Query<QueryStruct>("SELECT 1 as Column1, CURRENT_TIMESTAMP as Column2").ToList();

				Assert.That(list.Count, Is.EqualTo(1));
			}
		}
开发者ID:henleygao,项目名称:linq2db,代码行数:9,代码来源:DataExtensionsTest.cs


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