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)); }