本文整理汇总了C#中IDbProvider.CreateCommand方法的典型用法代码示例。如果您正苦于以下问题:C# IDbProvider.CreateCommand方法的具体用法?C# IDbProvider.CreateCommand怎么用?C# IDbProvider.CreateCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDbProvider
的用法示例。
在下文中一共展示了IDbProvider.CreateCommand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
_dbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient");
_dbProvider.ConnectionString =
@"Data Source=SPRINGQA;Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False";
IDbCommand command = _dbProvider.CreateCommand();
command.Connection = _dbProvider.CreateConnection();
ClearTestData(command);
CreateTestData(command);
}
示例2: CreateCommandAndEnlistTransaction
/// <summary>
/// Creates the command.
/// </summary>
/// <param name="dbProvider">The dbProvider.</param>
/// <param name="session">If session is not null, attaches the session's Connection and Transaction to the command and sets the command's Timeout property.</param>
/// <param name="commandType">Type of the command.</param>
/// <returns>the command</returns>
protected virtual IDbCommand CreateCommandAndEnlistTransaction(IDbProvider dbProvider, CommandType commandType, ISession session)
{
IDbCommand command = dbProvider.CreateCommand();
command.CommandType = commandType;
if (session != null)
{
command.Connection = session.Connection;
SetCommandTimeout(command, session.SessionFactory.DataSource.CommandTimeout);
// Assign transaction
if (session.Transaction != null)
{
session.Transaction.Enlist(command);
}
}
return command;
}
示例3: DbParameters
/// <summary>
/// Initializes a new instance of the <see cref="DbParameters"/> class.
/// </summary>
public DbParameters(IDbProvider dbProvider)
{
this.dbProvider = dbProvider;
dbCommand = dbProvider.CreateCommand();
dataParameterCollection = dbCommand.Parameters;
}