public static async Task <IDataReader> ExecuteReader(this IDbCommand cmd, CommandBehavior behavior, bool @async) { if (!@async) { return(cmd.ExecuteReader(behavior)); } DbCommand dbCommand = cmd as DbCommand; if (dbCommand != null) { return(await dbCommand.ExecuteReaderAsync(behavior)); } DbCommandDecorator dbCommandDecorator = cmd as DbCommandDecorator; if (dbCommandDecorator != null) { return(await dbCommandDecorator.ExecuteReaderAsync(behavior)); } return(cmd.ExecuteReader(behavior)); }
public static Task <object> ExecuteScalar(this IDbCommand cmd, bool @async) { if (!@async) { return(Task.FromResult(cmd.ExecuteScalar())); } DbCommand dbCommand = cmd as DbCommand; if (dbCommand != null) { return(dbCommand.ExecuteScalarAsync()); } DbCommandDecorator dbCommandDecorator = cmd as DbCommandDecorator; if (dbCommandDecorator != null) { return(dbCommandDecorator.ExecuteScalarAsync()); } return(Task.FromResult(cmd.ExecuteScalar())); }
public static Task <int> ExecuteNonQuery(this IDbCommand cmd, bool @async) { if (!@async) { return(Task.FromResult(cmd.ExecuteNonQuery())); } DbCommand dbCommand = cmd as DbCommand; if (dbCommand != null) { return(dbCommand.ExecuteNonQueryAsync()); } DbCommandDecorator dbCommandDecorator = cmd as DbCommandDecorator; if (dbCommandDecorator != null) { return(dbCommandDecorator.ExecuteNonQueryAsync()); } return(Task.FromResult(cmd.ExecuteNonQuery())); }