예제 #1
0
        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));
        }
예제 #2
0
파일: ProcessManager.cs 프로젝트: BS88/AI4E
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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());
        }