本文整理汇总了C#中CommandBehavior类的典型用法代码示例。如果您正苦于以下问题:C# CommandBehavior类的具体用法?C# CommandBehavior怎么用?C# CommandBehavior使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandBehavior类属于命名空间,在下文中一共展示了CommandBehavior类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ExecuteReader
public override DbDataReader ExecuteReader(string sql, CommandType cmdType, CommandBehavior cmdBehavior, params DbParameter[] cmdParams)
{
DbConnection conn = this.CreateConnection();
DbCommand cmd = this.CreateCommand(sql, cmdType, cmdParams);
this.PrepareCmd(cmd, conn);
return this.ExecuteReader(cmd, cmdBehavior);
}
开发者ID:erpframework,项目名称:spiderframework,代码行数:7,代码来源:MySqlHelper.cs
示例2: ExecuteReader
public static void ExecuteReader(SqlConnection connectionRef, string procedureName, SqlParameter[] parameters, CommandBehavior behavior, Action<SqlDataReader> readerCallback)
{
using (SqlCommand command = new SqlCommand(procedureName, connectionRef))
{
command.CommandType = CommandType.StoredProcedure;
command.CommandTimeout = 180;
if (parameters.Length > 0)
{
foreach (SqlParameter param in parameters)
{
command.Parameters.Add(param);
}
}
SqlDataReader reader = command.ExecuteReader(behavior);
try
{
readerCallback(reader);
}
finally
{
if (reader != null)
reader.Close();
}
}
}
开发者ID:jnicastri,项目名称:WDT_A2_Bank,代码行数:28,代码来源:SqlTools.cs
示例3: ExecuteReader
public IDataReader ExecuteReader(CommandBehavior behavior)
{
var reliableConnection = (ReliableSqlConnection) this.Connection;
return this.command.ExecuteReaderWithRetry(behavior,
reliableConnection.CommandRetryPolicy,
reliableConnection.ConnectionRetryPolicy);
}
开发者ID:krabishe,项目名称:BLToolkit.AzureSql,代码行数:7,代码来源:AzureSqlCommand.cs
示例4: GetDBCommand
public SqlCommand GetDBCommand(SqlConnection sqlcn, String CmdText, CommandType CmdType, CommandBehavior CmdBehavior, SqlParameter[] sqlParam)
{
SqlCommand sqlcmd = null;
try
{
sqlcmd = new SqlCommand(CmdText, sqlcn);
sqlcmd.CommandType = CmdType;
sqlcmd.CommandTimeout = GetCommandTimeout();
Utilities.DebugLogging.Log("CONNECTION STRING " + sqlcn.ConnectionString);
Utilities.DebugLogging.Log("COMMAND TEXT " + CmdText);
Utilities.DebugLogging.Log("COMMAND TYPE " + CmdType.ToString());
if (sqlParam != null)
Utilities.DebugLogging.Log("NUMBER OF PARAMS " + sqlParam.Length);
AddSQLParameters(sqlcmd, sqlParam);
}
catch (Exception ex)
{
Utilities.DebugLogging.Log(ex.Message);
Utilities.DebugLogging.Log(ex.StackTrace);
}
return sqlcmd;
}
开发者ID:TariqStuff,项目名称:ProfilesRNS,代码行数:27,代码来源:DataIO.cs
示例5: OdbcDataReader
internal OdbcDataReader(OdbcCommand command, CMDWrapper cmdWrapper, CommandBehavior commandbehavior)
{
this.command = command;
this._commandBehavior = commandbehavior;
this._cmdText = command.CommandText;
this._cmdWrapper = cmdWrapper;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:OdbcDataReader.cs
示例6: OracleDataReader
internal OracleDataReader(OracleCommand command, ArrayList refCursorParameterOrdinals, string statementText, CommandBehavior commandBehavior)
{
this.ObjectID = Interlocked.Increment(ref _objectTypeCount);
this._commandBehavior = commandBehavior;
this._statementText = statementText;
this._closeConnectionToo = this.IsCommandBehavior(CommandBehavior.CloseConnection);
if (CommandType.Text == command.CommandType)
{
this._keyInfoRequested = this.IsCommandBehavior(CommandBehavior.KeyInfo);
}
ArrayList list = new ArrayList();
int num2 = 0;
OracleDataReader reader = null;
for (int i = 0; i < refCursorParameterOrdinals.Count; i++)
{
int num3 = (int) refCursorParameterOrdinals[i];
OracleParameter parameter = command.Parameters[num3];
if (OracleType.Cursor == parameter.OracleType)
{
reader = (OracleDataReader) parameter.Value;
reader._recordsAffected = num2;
list.Add(reader);
parameter.Value = DBNull.Value;
}
else
{
num2 += (int) parameter.Value;
}
}
this._refCursorDataReaders = new OracleDataReader[list.Count];
list.CopyTo(this._refCursorDataReaders);
this._nextRefCursor = 0;
this.NextResultInternal();
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:OracleDataReader.cs
示例7: ExecuteReaderObservable
/// <summary>
/// Initiates the asynchronous execution of the Transact-SQL statement or stored procedure using one of the
/// <see cref="CommandBehavior"/> values, and retrieving one or more result sets from the server.
/// </summary>
/// <param name="command">The <see cref="SqlCommand"/> to be executed.</param>
/// <param name="behavior">One of the <see cref="CommandBehavior"/> values.</param>
/// <returns>A singleton observable sequence containing a <see cref="SqlDataReader"/> object that provides access to
/// the result sets of the specified <paramref name="command"/>.</returns>
public static IObservable<SqlDataReader> ExecuteReaderObservable(this SqlCommand command, CommandBehavior behavior)
{
Contract.Requires(command != null);
Contract.Ensures(Contract.Result<IObservable<SqlDataReader>>() != null);
return Observable.StartAsync(cancel => command.ExecuteReaderAsync(behavior, cancel));
}
开发者ID:ibebbs,项目名称:Rxx,代码行数:15,代码来源:SqlCommandExtensions.cs
示例8: ExecuteReaderAsyncWithRetry
public static Task<SqlDataReader> ExecuteReaderAsyncWithRetry(
SqlCommand command,
CommandBehavior behavior,
IRetryPolicy retryPolicy)
{
return retryPolicy.ExecuteAsyncWithRetry(() => command.ExecuteReaderAsync(behavior));
}
开发者ID:cleverguy25,项目名称:Fleeting,代码行数:7,代码来源:SqlCommandExtensions.cs
示例9: RunStoredProcedure
/// Runs a stored procedure
/// </summary>
/// <param name="procedureName"></param>
/// <param name="QueryParameters"></param>
/// <param name="OutputParameters"></param>
/// <param name="DB"></param>
public virtual void RunStoredProcedure(IDbConnection connection, string procedureName,
IEnumerable<IDataParameter> inputParameters,
IEnumerable<IDataParameter> outputParameters,
IDbTransaction transaction,
CommandBehavior commandBehavior)
{
SqlCommand cmd = new SqlCommand(procedureName, (SqlConnection)connection);
cmd.CommandType = CommandType.StoredProcedure;
ProcessSql(procedureName, inputParameters);
foreach (var parm in inputParameters)
{
cmd.Parameters.Add(parm);
}
if (outputParameters != null)
{
foreach (SqlParameter parm in outputParameters)
{
parm.Direction = ParameterDirection.Output;
//OutputParameters[i].Value = -1;
cmd.Parameters.Add(parm);
}
}
ExecuteSqlFinal(new Action(() =>
{
cmd.ExecuteScalar();
}));
if (commandBehavior == CommandBehavior.CloseConnection)
{
connection.Close();
}
OnQueryComplete();
}
开发者ID:jamietre,项目名称:IQMap,代码行数:41,代码来源:MSSQLDataStorageController.cs
示例10: ExecuteReader
public IDataReader ExecuteReader(CommandBehavior behavior)
{
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, string.Format("ExecuteReader({0})", behavior), dur)))
{
return command.ExecuteReader(behavior);
}
}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:7,代码来源:DbCommandProxy.cs
示例11: ExecuteDataReader
public IDataReader ExecuteDataReader(Saga.Data.IQueryProvider query, CommandBehavior behavior)
{
MySqlConnection connection = ConnectionPool.Request();
MySqlCommand command = new MySqlCommand();
MySqlDataReader reader = null;
try
{
command.CommandText = query.CmdText;
command.Connection = connection;
foreach (KeyValuePair<string, object> pair in query.Parameters)
{
command.Parameters.AddWithValue(pair.Key, pair.Value);
}
return command.ExecuteReader(behavior);
}
catch (Exception e)
{
__dbtracelog.WriteError("Database", e.Message);
return null;
}
finally
{
//ALWAYS CLOSE THE CONNECTION AND REPOOL THE ITEMS
if (reader != null && reader.IsClosed == false) reader.Close();
ConnectionPool.Release(connection);
}
}
开发者ID:ELMASTERS,项目名称:SagaRevised,代码行数:30,代码来源:MysqlProvider.Plugin.cs
示例12: ExecuteProfilableReader
public static DbDataReader ExecuteProfilableReader(this DbCommand dbCommand, CommandBehavior commandBehavior = CommandBehavior.Default)
{
if (!(dbCommand is ProfilableDbCommand))
return (new ProfilableDbCommand(dbCommand, dbCommand.Connection)).ExecuteReader(commandBehavior);
else
return dbCommand.ExecuteReader(commandBehavior);
}
开发者ID:RichCzyzewski,项目名称:SqlClientProfiler,代码行数:7,代码来源:DbCommandExtensions.cs
示例13: Count
public virtual int Count(IDbConnection connection, string query, IEnumerable<IDataParameter> parameters = null,
CommandBehavior commandBehavior = CommandBehavior.Default)
{
ValidateQueryType(query, "select");
string countQuery = "SELECT COUNT(*) FROM (" + query + ") q";
return RunQueryScalar(connection,countQuery, parameters,null,commandBehavior);
}
开发者ID:jamietre,项目名称:IQMap,代码行数:7,代码来源:SqlDataStorageController.cs
示例14: RunQuery
public virtual IDataReader RunQuery(IDbConnection connection, string query,
IEnumerable<IDataParameter> parameters = null,
int firstRow=-1,
int totalRows=-1,
IDbTransaction transaction = null,
CommandBehavior commandBehavior = CommandBehavior.Default)
{
IDataReader dataReader = null;
string sql;
if (firstRow >= 0 || totalRows >= 0)
{
sql = GetQueryForRows(query, firstRow, totalRows);
} else {
sql = query;
}
sql = ProcessSql(sql,parameters);
using (IDbCommand cmd = GetCommand(connection, sql, parameters, transaction))
{
ExecuteSqlFinal(new Action(() =>
{
dataReader = cmd.ExecuteReader(commandBehavior);
}));
cmd.Parameters.Clear();
}
OnQueryComplete();
return dataReader;
}
开发者ID:jamietre,项目名称:IQMap,代码行数:31,代码来源:SqlDataStorageController.cs
示例15: GetDBCommand
public SqlCommand GetDBCommand(SqlConnection sqlcn, String CmdText, CommandType CmdType, CommandBehavior CmdBehavior, SqlParameter[] sqlParam)
{
SqlCommand sqlcmd = new SqlCommand(CmdText, sqlcn);
sqlcmd.CommandType = CmdType;
AddSQLParameters(sqlcmd, sqlParam);
return sqlcmd;
}
开发者ID:EricMeeks,项目名称:ProfilesRNSBeta,代码行数:8,代码来源:DataIO.cs
示例16: ExecuteDbDataReader
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
{
string query, verb, url;
ParseCommantText(out query, out verb, out url);
var json = ElasticDbConnection.ExecuteRequest(verb, url, query);
var reader = new ElasticDbDataReader(json, ElasticDbConnection.ResultParserTypes);
return reader;
}
开发者ID:krisdaniels,项目名称:ElasticConnection,代码行数:8,代码来源:ElasticDbCommand.cs
示例17: RunStoredProcedureDataset
public virtual SqlDataReader RunStoredProcedureDataset(IDbConnection connection,
string procedureName,
IEnumerable<IDataParameter> queryParameters,
IDbTransaction transaction,
CommandBehavior commandBehavior)
{
return RunStoredProcedureDataset(connection,procedureName, queryParameters, null,transaction, commandBehavior);
}
开发者ID:jamietre,项目名称:IQMap,代码行数:8,代码来源:MSSQLDataStorageController.cs
示例18: ExecuteReaderSyncOrAsync
public static Task<SqlDataReader> ExecuteReaderSyncOrAsync(this SqlCommand command, CommandBehavior cb, CancellationToken token, Random rnd)
{
return AsyncUtils.SyncOrAsyncMethod(
() => command.ExecuteReader(cb),
() => command.ExecuteReaderAsync(cb, token),
AsyncUtils.ChooseSyncAsyncMode(rnd)
);
}
开发者ID:Corillian,项目名称:corefx,代码行数:8,代码来源:Extensions.cs
示例19: BeginExecuteReader
public override IAsyncResult BeginExecuteReader(AsyncCallback callback, object state, CommandBehavior behavior)
{
if (IsTraced)
{
Tracer.Instance.EnterFunction(TraceClass, "AsyncExecuteReader", new string[] { "CommandText", "callback", "state", "behavior", "Parameters" }, new object[] { this.CommandText, callback, state, behavior, base.GetTraceParameters(true) });
}
return ((SqlCommand) base.DbCommand).BeginExecuteReader(callback, state, behavior);
}
开发者ID:jango2015,项目名称:CodePorter,代码行数:8,代码来源:SqlAccessCommand.cs
示例20: MockDataReader
public MockDataReader(MockDataCommand command, CommandBehavior behavior)
: base()
{
if (command == null) throw new ArgumentNullException(nameof(command));
this.Command = command;
this.CommandBehavior = behavior;
}
开发者ID:slorion,项目名称:nlight,代码行数:8,代码来源:MockDataReader.cs
注:本文中的CommandBehavior类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论