예제 #1
0
            public ValueTask <System.Int64> LongCountAsync(QueryAdapterBase queryAdapter, IQueryable source, CancellationToken cancellation)
            {
                if (source is not IQueryable <T> typedQueryable)
                {
                    typedQueryable = source.Cast <T>();
                }

                return(queryAdapter.LongCountAsync(typedQueryable, cancellation));
            }
예제 #2
0
            public AsyncTypeAwaitable MaxAsync(QueryAdapterBase queryAdapter, IQueryable source, CancellationToken cancellation)
            {
                if (source is not IQueryable <T> typedQueryable)
                {
                    typedQueryable = source.Cast <T>();
                }

                var task = queryAdapter.MaxAsync(typedQueryable, cancellation);

                return(task.AsTypeAwaitable());
            }
        public AsyncQueryProvider(QueryAdapterBase queryAdapter, MethodProcessor methodProcessor)
        {
            if (queryAdapter is null)
            {
                throw new ArgumentNullException(nameof(queryAdapter));
            }

            if (methodProcessor is null)
            {
                throw new ArgumentNullException(nameof(methodProcessor));
            }

            QueryAdapter     = queryAdapter;
            _methodProcessor = methodProcessor;
        }
예제 #4
0
            public ValueTask <System.Int64> LongCountAsync(QueryAdapterBase queryAdapter, IQueryable source, Expression predicate, CancellationToken cancellation)
            {
                if (source is not IQueryable <T> typedQueryable)
                {
                    typedQueryable = source.Cast <T>();
                }

                if (predicate is UnaryExpression unaryExpression && unaryExpression.NodeType == ExpressionType.Quote)
                {
                    predicate = unaryExpression.Operand;
                }

                // TODO: Can we convert the selector if it is not of the appropriate type?
                return(queryAdapter.LongCountAsync(typedQueryable, (Expression <Func <T, bool> >)predicate, cancellation));
            }
예제 #5
0
            public AsyncTypeAwaitable SingleOrDefaultAsync(
                QueryAdapterBase queryAdapter,
                IQueryable source,
                Expression predicate,
                CancellationToken cancellation)
            {
                if (source is not IQueryable <T> typedQueryable)
                {
                    typedQueryable = source.Cast <T>();
                }

                if (predicate is UnaryExpression unaryExpression && unaryExpression.NodeType == ExpressionType.Quote)
                {
                    predicate = unaryExpression.Operand;
                }

                // TODO: Can we convert the selector if it is not of the appropriate type?
                var task = queryAdapter.SingleOrDefaultAsync(typedQueryable, (Expression <Func <T, bool> >)predicate, cancellation);

                return(task.AsTypeAwaitable());
            }
예제 #6
0
 public static AsyncQueryable <T> Create <T>(QueryAdapterBase queryAdapter, MethodProcessor methodProcessor)
 {
     return(new AsyncQueryable <T>(queryAdapter, methodProcessor));
 }