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 DocumentTransaction(DocumentStore store, Guid commitId, IsolationLevel level, StoreStats storeStats) { Store = store; this.storeStats = storeStats; managedConnection = store.Database.Connect(); SqlConnection = managedConnection.Connection; if (Transaction.Current == null) { SqlTransaction = SqlConnection.BeginTransaction(level); } CommitId = commitId; }
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); } }