本文整理汇总了C#中LinqToDB.Data.DataConnection.SetCommand方法的典型用法代码示例。如果您正苦于以下问题:C# DataConnection.SetCommand方法的具体用法?C# DataConnection.SetCommand怎么用?C# DataConnection.SetCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToDB.Data.DataConnection
的用法示例。
在下文中一共展示了DataConnection.SetCommand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TearDown
protected override void TearDown()
{
using (var dbManager = new DataConnection("PerformanceTest"))
dbManager
.SetCommand("TRUNCATE TABLE Simplests")
.Execute();
}
示例2: Test1
public void Test1([IncludeDataContexts("Northwind")] string context)
{
using (var conn = new DataConnection(SqlServerFactory.GetDataProvider(), "Server=.;Database=Northwind;Integrated Security=SSPI"))
{
conn.SetCommand("SELECT 1");
var rd = conn.Command.ExecuteReader();
if (rd.Read())
{
var dp = conn.DataProvider;
var p = Expression.Parameter(typeof(IDataReader));
var dr = Expression.Convert(p, dp.DataReaderType);
var ex = (Expression<Func<IDataReader,int,int>>)dp.GetReaderExpression(conn.MappingSchema, rd, 0, dr, typeof(int));
var func = ex.Compile();
do
{
var value = func(rd, 0);
Assert.AreEqual(1, value);
} while (rd.Read());
}
else
{
Assert.Fail();
}
}
}
示例3: Test1
public void Test1(string context)
{
var connectionString = ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString;
using (var conn = new DataConnection(SqlServerTools.GetDataProvider(), connectionString))
{
conn.SetCommand("SELECT 1");
var rd = conn.Command.ExecuteReader();
if (rd.Read())
{
var dp = conn.DataProvider;
var p = Expression.Parameter(typeof(IDataReader));
var dr = Expression.Convert(p, dp.DataReaderType);
var ex = (Expression<Func<IDataReader,int,int>>)dp.GetReaderExpression(conn.MappingSchema, rd, 0, dr, typeof(int));
var func = ex.Compile();
do
{
var value = func(rd, 0);
Assert.AreEqual(1, value);
} while (rd.Read());
}
else
{
Assert.Fail();
}
}
}