public async Task Execute(CancellationToken token = default(CancellationToken)) { var map = _identityMap.ForQuery(); if (!_items.Any()) { return; } await _runner.ExecuteAsync(_command, async (cmd, tk) => { using (var reader = await _command.ExecuteReaderAsync(tk).ConfigureAwait(false)) { await _items[0].Read(reader, map, token).ConfigureAwait(false); var others = _items.Skip(1).ToArray(); foreach (var item in others) { var hasNext = await reader.NextResultAsync(token).ConfigureAwait(false); if (!hasNext) { throw new InvalidOperationException("There is no next result to read over."); } await item.Read(reader, map, token).ConfigureAwait(false); } } return(0); }, token).ConfigureAwait(false); }
public IReadOnlyList <T> Query <T>(string sql, params object[] parameters) { assertNotDisposed(); var handler = new UserSuppliedQueryHandler <T>(_store, sql, parameters); return(_connection.Fetch(handler, _identityMap.ForQuery(), null, Tenant)); }
public IList <T> Query <T>(string sql, params object[] parameters) { assertNotDisposed(); var handler = new UserSuppliedQueryHandler <T>(_schema, _serializer, sql, parameters); return(_connection.Fetch(handler, _identityMap.ForQuery(), null)); }
public static Task <IList <T> > ResolveAsync <T>(this IManagedConnection runner, NpgsqlCommand cmd, ISelector <T> selector, IIdentityMap map, QueryStatistics stats, CancellationToken token) { var selectMap = map.ForQuery(); return(runner.ExecuteAsync(cmd, async(c, tkn) => { var list = new List <T>(); using (var reader = await cmd.ExecuteReaderAsync(tkn).ConfigureAwait(false)) { while (await reader.ReadAsync(tkn).ConfigureAwait(false)) { list.Add(selector.Resolve(reader, selectMap, stats)); } } return list.As <IList <T> >(); }, token)); }
public static IList <T> Resolve <T>(this IManagedConnection runner, NpgsqlCommand cmd, ISelector <T> selector, IIdentityMap map, QueryStatistics stats) { var selectMap = map.ForQuery(); return(runner.Execute(cmd, c => { var list = new List <T>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { list.Add(selector.Resolve(reader, selectMap, stats)); } } return list; })); }