public IReadOnlyList <T> Handle(DbDataReader reader, IMartenSession session) { var list = new List <T>(); if (reader.Read()) { _statistics.TotalResults = reader.GetFieldValue <int>(_countIndex); var item = _selector.Resolve(reader); list.Add(item); } else { // no data _statistics.TotalResults = 0; return(list); } // Get the rest of the data while (reader.Read()) { var item = _selector.Resolve(reader); list.Add(item); } return(list); }
public TSearched Resolve(DbDataReader reader, IIdentityMap map) { var included = _resolver.Resolve(StartingIndex, reader, map); _callback(included); return(_inner.Resolve(reader, map)); }
public void Read(DbDataReader reader) { while (reader.Read()) { var item = _selector.Resolve(reader); _callback(item); } }
public TSearched Resolve(DbDataReader reader, IIdentityMap map, QueryStatistics stats) { var included = storage.Resolve(StartingIndex, reader, map); _callback(included); return(_inner.Resolve(reader, map, stats)); }
public static IReadOnlyList <T> Read <T>(this ISelector <T> selector, DbDataReader reader, IIdentityMap map, QueryStatistics stats) { var list = new List <T>(); while (reader.Read()) { list.Add(selector.Resolve(reader, map, stats)); } return(list); }
public IReadOnlyList <T> Handle(DbDataReader reader, IMartenSession session) { var list = new List <T>(); while (reader.Read()) { var item = _selector.Resolve(reader); list.Add(item); } return(list); }
internal static T LoadOne <T>(this IManagedConnection connection, NpgsqlCommand command, ISelector <T> selector) { using (var reader = connection.ExecuteReader(command)) { if (!reader.Read()) { return(default(T)); } return(selector.Resolve(reader)); } }
public void can_resolve_and_callback_from_the_reader() { var reader = Substitute.For <DbDataReader>(); var issue = new Issue(); var user = new User(); var map = new NulloIdentityMap(null); theResolver.Resolve(3, reader, map).Returns(user); inner.Resolve(reader, map).Returns(issue); theSelector.Resolve(reader, map).ShouldBe(issue); theCallback.Received().Invoke(user); }
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; })); }
public T Handle(DbDataReader reader, IIdentityMap map) { var hasResult = reader.Read(); if (!hasResult) { if (_canBeNull) { return(default(T)); } throw new InvalidOperationException(NoElementsMessage); } var result = _selector.Resolve(reader, map); if (!_canBeMultiples && reader.Read()) { throw new InvalidOperationException(MoreThanOneElementMessage); } return(result); }
public T Handle(DbDataReader reader, IIdentityMap map) { return(reader.Read() ? _selector.Resolve(reader, map) : default(T)); }
public T Resolve(DbDataReader reader) { return((T)_inner.Resolve(reader)); }
public T Resolve(DbDataReader reader, IIdentityMap map, QueryStatistics stats) { return(_inner.Resolve(reader, map, stats)); }
public T Handle(DbDataReader reader, IIdentityMap map, QueryStatistics stats) { return(reader.Read() ? _selector.Resolve(reader, map, stats) : default(T)); }
public T Resolve(DbDataReader reader, IIdentityMap map) { _stats.TotalResults = reader.GetInt64(StartingIndex); return(_inner.Resolve(reader, map)); }
public T Resolve(DbDataReader reader, IIdentityMap map) { return(_inner.Resolve(reader, map)); }
internal T?LoadOne <T>(NpgsqlCommand command, ISelector <T> selector) { using var reader = ExecuteReader(command); return(!reader.Read() ? default : selector.Resolve(reader)); }
public T Resolve(DbDataReader reader, IIdentityMap map, QueryStatistics stats) { stats.TotalResults = reader.GetInt64(StartingIndex); return(_inner.Resolve(reader, map, stats)); }