void InternalExecute(ManagedConnection managedConnection, string sql, List <Parameter> parameters, int expectedRowCount) { var fastParameters = new FastDynamicParameters(parameters); var rowcount = managedConnection.Connection.Execute(sql, fastParameters); Interlocked.Increment(ref numberOfRequests); if (rowcount != expectedRowCount) { throw new ConcurrencyException(); } }
public IEnumerable <T> RawQuery <T>(string sql, object parameters = null) { var hdbParams = parameters as IEnumerable <Parameter>; if (hdbParams != null) { parameters = new FastDynamicParameters(hdbParams); } store.Logger.Debug(sql); using (var connection = Connect()) { return(connection.Connection.Query <T>(sql, parameters)); } }
public int RawExecute(string sql, object parameters = null) { var hdbParams = parameters as IEnumerable <Parameter>; if (hdbParams != null) { parameters = new FastDynamicParameters(hdbParams); } store.Logger.Debug(sql); using (var connection = Connect()) { var result = connection.Connection.Execute(sql, parameters); connection.Complete(); return(result); } }
IEnumerable <T> InternalQuery <T>(ManagedConnection connection, SqlBuilder sql, object parameters, bool hasTotalsQuery, out QueryStats stats) { var normalizedParameters = new FastDynamicParameters( parameters as IEnumerable <Parameter> ?? ConvertToParameters <T>(parameters)); if (hasTotalsQuery) { using (var reader = connection.Connection.QueryMultiple(sql.ToString(), normalizedParameters)) { stats = reader.Read <QueryStats>(buffered: true).Single(); return(reader.Read <T, object, T>((first, second) => first, "RowNumber", buffered: true)); } } using (var reader = connection.Connection.QueryMultiple(sql.ToString(), normalizedParameters)) { List <T> rows = reader.Read <T, object, T>((first, second) => first, "RowNumber", buffered: true).ToList(); stats = new QueryStats { TotalResults = rows.Count }; return(rows); } }