コード例 #1
0
        internal AggregateQueryProvider(IQueryable queryable, IAggregateQueryable <TEntity> aggregateQueryable, IAggregateFluent <TEntity> aggregateFluent)
        {
            queryable.NotNull(nameof(queryable));
            this.queryProvider      = queryable.Provider.NotNull(nameof(queryable.Provider));
            this.aggregateQueryable = aggregateQueryable.NotNull(nameof(aggregateQueryable));
            AggregateFluent         = aggregateFluent.NotNull(nameof(aggregateFluent));

            AddQueryToPipeline(queryable);
        }
コード例 #2
0
        internal AggregateQueryable(IAggregateFluent <TEntity> aggregate, IMongoQueryable <TEntity> queryable)
        {
            aggregate.NotNull(nameof(aggregate));
            queryable.NotNull(nameof(queryable));
            queryable.ElementType.NotNull(nameof(queryable.ElementType));
            queryable.Expression.NotNull(nameof(queryable.Expression));

            aggregateQueryProvider = new AggregateQueryProvider <TEntity>(queryable, this, aggregate);
            ElementType            = queryable.ElementType;
            Expression             = queryable.Expression;
        }
コード例 #3
0
        public static IAggregateQueryable <TEntity> AsAggregateQueryable <TEntity>(this IAggregateFluent <TEntity> aggregate)
        {
            aggregate.NotNull(nameof(aggregate));

            var field = aggregate.GetType().GetTypeInfo().GetField("_collection", BindingFlags.Instance | BindingFlags.NonPublic);

            if (!(field?.GetValue(aggregate) is IMongoCollection <TEntity> collection))
            {
                throw new NotSupportedException("This type of IAggregateFluent<> dose not support converting to IAggregateQueryable<>");
            }

            var queryable = collection.AsQueryable(aggregate.Options);

            return(new AggregateQueryable <TEntity>(aggregate, queryable));
        }