public static IAsyncEnumerable <TData> GetAllAsync <TData>(this IQueryableDataStore dataStore, CancellationToken cancellation = default) { if (dataStore == null) { throw new ArgumentNullException(nameof(dataStore)); } return(dataStore.QueryAsync <TData, TData>(p => p, cancellation)); }
public IProcessManagerAttachments <TState> Attach <TEvent>(Expression <Func <TEvent, TState, bool> > predicate) { Func <object, Task <TState> > mapping = o => { var evt = (TEvent)o; var dBPredicate = ParameterReplacer.Replace <Func <TEvent, TState, bool>, Func <TState, bool> >(predicate, predicate.Parameters.First(), Expression.Constant(evt)); return(_dataStore.QueryAsync <TState, TState>(queryable => queryable.Where(dBPredicate)).FirstOrDefault()); }; _mappings[typeof(TEvent)] = mapping; return(this); }
public static IAsyncEnumerable <TData> QueryAsync <TData>(this IQueryableDataStore dataStore, Func <IQueryable <TData>, IQueryable <TData> > queryShaper, CancellationToken cancellation = default) where TData : class { if (dataStore == null) { throw new ArgumentNullException(nameof(dataStore)); } if (queryShaper == null) { throw new ArgumentNullException(nameof(queryShaper)); } return(dataStore.QueryAsync(queryShaper, cancellation)); }
public static IAsyncEnumerable <TData> GetByAsync <TData>(this IQueryableDataStore dataStore, Expression <Func <TData, bool> > predicate, CancellationToken cancellation = default) { if (dataStore == null) { throw new ArgumentNullException(nameof(dataStore)); } if (predicate == null) { throw new ArgumentNullException(nameof(predicate)); } return(dataStore.QueryAsync <TData, TData>(p => p.Where(predicate), cancellation)); }
public static IAsyncEnumerable <TResult> GetAllAsync <TData, TResult>(this IQueryableDataStore dataStore, Expression <Func <TData, TResult> > projection, CancellationToken cancellation = default) { if (dataStore == null) { throw new ArgumentNullException(nameof(dataStore)); } if (projection == null) { throw new ArgumentNullException(nameof(projection)); } return(dataStore.QueryAsync <TData, TResult>(p => p.Select(projection), cancellation)); }
public static Task <TResult> GetSingleAsync <TData, TResult>(this IQueryableDataStore dataStore, Expression <Func <TData, bool> > predicate, Expression <Func <TData, TResult> > projection, CancellationToken cancellation = default) { if (dataStore == null) { throw new ArgumentNullException(nameof(dataStore)); } if (predicate == null) { throw new ArgumentNullException(nameof(predicate)); } if (projection == null) { throw new ArgumentNullException(nameof(projection)); } return(dataStore.QueryAsync <TData, TResult>(p => p.Where(predicate).Select(projection), cancellation).FirstOrDefault()); }