本文整理汇总了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));
}
}
示例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));
}
}
示例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));
}
}
示例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));
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
}
示例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();
}
}
示例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));
}
}