public override IAggregateFluent <TNewResult> GraphLookup <TFrom, TConnectFrom, TConnectTo, TStartWith, TAsElement, TAs, TNewResult>(
     IMongoCollection <TFrom> from,
     FieldDefinition <TFrom, TConnectFrom> connectFromField,
     FieldDefinition <TFrom, TConnectTo> connectToField,
     AggregateExpressionDefinition <TResult, TStartWith> startWith,
     FieldDefinition <TNewResult, TAs> @as,
     FieldDefinition <TAsElement, int> depthField,
     AggregateGraphLookupOptions <TFrom, TAsElement, TNewResult> options = null)
 {
     return(WithPipeline(_pipeline.GraphLookup(from, connectFromField, connectToField, startWith, @as, depthField, options)));
 }
Exemple #2
0
 /// <inheritdoc />
 public virtual IAggregateFluent <TNewResult> GraphLookup <TFrom, TConnectFrom, TConnectTo, TStartWith, TAsElement, TAs, TNewResult>(
     IMongoCollection <TFrom> from,
     FieldDefinition <TFrom, TConnectFrom> connectFromField,
     FieldDefinition <TFrom, TConnectTo> connectToField,
     AggregateExpressionDefinition <TResult, TStartWith> startWith,
     FieldDefinition <TNewResult, TAs> @as,
     FieldDefinition <TAsElement, int> depthField,
     AggregateGraphLookupOptions <TFrom, TAsElement, TNewResult> options = null)
     where TAs : IEnumerable <TAsElement>
 {
     throw new NotImplementedException();
 }
Exemple #3
0
        public override IAggregateFluent <TNewResult> GraphLookup <TNewResult, TFrom, TConnect, TConnectFrom, TStartWith, TAs, TAsEnumerable>(
            IMongoCollection <TFrom> from,
            FieldDefinition <TFrom, TConnectFrom> connectFromField,
            FieldDefinition <TFrom, TConnect> connectToField,
            AggregateExpressionDefinition <TResult, TStartWith> startWith,
            FieldDefinition <TNewResult, TAsEnumerable> @as,
            FieldDefinition <TAs, int> depthField,
            AggregateGraphLookupOptions <TNewResult, TFrom, TConnect, TConnectFrom, TStartWith, TAs, TAsEnumerable> options = null)
        {
            Ensure.IsNotNull(from, nameof(from));
            Ensure.IsNotNull(connectFromField, nameof(connectFromField));
            Ensure.IsNotNull(connectToField, nameof(connectToField));
            Ensure.IsNotNull(startWith, nameof(startWith));
            Ensure.IsNotNull(@as, nameof(@as));
            Ensure.That(from.Database.DatabaseNamespace.Equals(_collection.Database.DatabaseNamespace), "From collection must be from the same database.", nameof(from));
            Ensure.That(IsTConnectOrEnumerableTConnect <TConnectFrom, TConnect>(), "TConnectFrom must be either TConnect or a type that implements IEnumerable<TConnect>.", nameof(TConnectFrom));
            Ensure.That(IsTConnectOrEnumerableTConnect <TStartWith, TConnect>(), "TStartWith must be either TConnect or a type that implements IEnumerable<TConnect>.", nameof(TStartWith));

            const string operatorName = "$graphLookup";
            var          stage        = new DelegatedPipelineStageDefinition <TResult, TNewResult>(
                operatorName,
                (s, sr) =>
            {
                var resultSerializer         = s;
                var newResultSerializer      = options?.NewResultSerializer ?? sr.GetSerializer <TNewResult>();
                var fromSerializer           = options?.FromSerializer ?? sr.GetSerializer <TFrom>();
                var asSerializer             = options?.AsSerializer ?? sr.GetSerializer <TAs>();
                var renderedConnectToField   = connectToField.Render(fromSerializer, sr);
                var renderedStartWith        = startWith.Render(resultSerializer, sr);
                var renderedConnectFromField = connectFromField.Render(fromSerializer, sr);
                var renderedAs         = @as.Render(newResultSerializer, sr);
                var renderedDepthField = depthField?.Render(asSerializer, sr);
                var renderedRestrictSearchWithMatch = options?.RestrictSearchWithMatch?.Render(fromSerializer, sr);
                var document = new BsonDocument
                {
                    { operatorName, new BsonDocument
                      {
                          { "from", from.CollectionNamespace.CollectionName },
                          { "connectFromField", renderedConnectFromField.FieldName },
                          { "connectToField", renderedConnectToField.FieldName },
                          { "startWith", renderedStartWith },
                          { "as", renderedAs.FieldName },
                          { "depthField", () => renderedDepthField.FieldName, renderedDepthField != null },
                          { "maxDepth", () => options.MaxDepth.Value, options != null && options.MaxDepth.HasValue },
                          { "restrictSearchWithMatch", renderedRestrictSearchWithMatch, renderedRestrictSearchWithMatch != null }
                      } }
                };
                return(new RenderedPipelineStageDefinition <TNewResult>(operatorName, document, newResultSerializer));
            });

            return(AppendStage <TNewResult>(stage));
        }
 /// <summary>
 /// Appends a $graphLookup stage to the pipeline.
 /// </summary>
 /// <typeparam name="TResult">The type of the result.</typeparam>
 /// <typeparam name="TNewResult">The type of the new result (must be same as TResult with an additional as field).</typeparam>
 /// <typeparam name="TFrom">The type of the from documents.</typeparam>
 /// <typeparam name="TConnectFrom">The type of the connect from field (must be either TConnectTo or a type that implements IEnumerable{TConnectTo}).</typeparam>
 /// <typeparam name="TConnectTo">The type of the connect to field.</typeparam>
 /// <typeparam name="TStartWith">The type of the start with expression (must be either TConnectTo or a type that implements IEnumerable{TConnectTo}).</typeparam>
 /// <typeparam name="TAs">The type of the as field.</typeparam>
 /// <param name="aggregate">The aggregate.</param>
 /// <param name="from">The from collection.</param>
 /// <param name="connectFromField">The connect from field.</param>
 /// <param name="connectToField">The connect to field.</param>
 /// <param name="startWith">The start with value.</param>
 /// <param name="as">The as field.</param>
 /// <param name="options">The options.</param>
 /// <returns>The fluent aggregate interface.</returns>
 public static IAggregateFluent <TNewResult> GraphLookup <TResult, TFrom, TConnectFrom, TConnectTo, TStartWith, TAs, TNewResult>(
     this IAggregateFluent <TResult> aggregate,
     IMongoCollection <TFrom> from,
     Expression <Func <TFrom, TConnectFrom> > connectFromField,
     Expression <Func <TFrom, TConnectTo> > connectToField,
     Expression <Func <TResult, TStartWith> > startWith,
     Expression <Func <TNewResult, TAs> > @as,
     AggregateGraphLookupOptions <TFrom, TFrom, TNewResult> options = null)
     where TAs : IEnumerable <TFrom>
 {
     Ensure.IsNotNull(aggregate, nameof(aggregate));
     return(aggregate.AppendStage(PipelineStageDefinitionBuilder.GraphLookup(from, connectFromField, connectToField, startWith, @as, options, aggregate.Options?.TranslationOptions)));
 }
Exemple #5
0
        /// <summary>
        /// Appends a $graphLookup stage to the pipeline.
        /// </summary>
        /// <typeparam name="TResult">The type of the result.</typeparam>
        /// <typeparam name="TNewResult">The type of the new result (must be same as TResult with an additional as field).</typeparam>
        /// <typeparam name="TFrom">The type of the from documents.</typeparam>
        /// <typeparam name="TConnect">The type of the connect field.</typeparam>
        /// <typeparam name="TConnectFrom">The type of the connect from field (must be either TConnect or a type that implements IEnumerable{TConnect}).</typeparam>
        /// <typeparam name="TStartWith">The type of the start with expression (must be either TConnect or a type that implements IEnumerable{TConnect}).</typeparam>
        /// <typeparam name="TAsEnumerable">The type of the enumerable as field.</typeparam>
        /// <param name="aggregate">The aggregate.</param>
        /// <param name="from">The from collection.</param>
        /// <param name="connectFromField">The connect from field.</param>
        /// <param name="connectToField">The connect to field.</param>
        /// <param name="startWith">The start with value.</param>
        /// <param name="as">The as field.</param>
        /// <param name="options">The options.</param>
        /// <returns>The fluent aggregate interface.</returns>
        public static IAggregateFluent <TNewResult> GraphLookup <TResult, TNewResult, TFrom, TConnect, TConnectFrom, TStartWith, TAsEnumerable>(
            this IAggregateFluent <TResult> aggregate,
            IMongoCollection <TFrom> from,
            FieldDefinition <TFrom, TConnectFrom> connectFromField,
            FieldDefinition <TFrom, TConnect> connectToField,
            AggregateExpressionDefinition <TResult, TStartWith> startWith,
            FieldDefinition <TNewResult, TAsEnumerable> @as,
            AggregateGraphLookupOptions <TNewResult, TFrom, TConnect, TConnectFrom, TStartWith, TFrom, TAsEnumerable> options = null)
            where TAsEnumerable : IEnumerable <TFrom>
        {
            Ensure.IsNotNull(aggregate, nameof(aggregate));
            Ensure.IsNotNull(from, nameof(from));
            Ensure.IsNotNull(connectFromField, nameof(connectFromField));
            Ensure.IsNotNull(connectToField, nameof(connectToField));
            Ensure.IsNotNull(startWith, nameof(startWith));
            Ensure.IsNotNull(@as, nameof(@as));
            var depthField = (FieldDefinition <TFrom, int>)null;

            return(aggregate.GraphLookup(from, connectFromField, connectToField, startWith, @as, depthField, options));
        }
Exemple #6
0
        /// <summary>
        /// Appends a $graphLookup stage to the pipeline.
        /// </summary>
        /// <typeparam name="TResult">The type of the result.</typeparam>
        /// <typeparam name="TNewResult">The type of the new result (must be same as TResult with an additional as field).</typeparam>
        /// <typeparam name="TFrom">The type of the from documents.</typeparam>
        /// <typeparam name="TConnect">The type of the connect field.</typeparam>
        /// <typeparam name="TConnectFrom">The type of the connect from field (must be either TConnect or a type that implements IEnumerable{TConnect}).</typeparam>
        /// <typeparam name="TStartWith">The type of the start with expression (must be either TConnect or a type that implements IEnumerable{TConnect}).</typeparam>
        /// <typeparam name="TAsEnumerable">The type of the enumerable as field.</typeparam>
        /// <param name="aggregate">The aggregate.</param>
        /// <param name="from">The from collection.</param>
        /// <param name="connectFromField">The connect from field.</param>
        /// <param name="connectToField">The connect to field.</param>
        /// <param name="startWith">The start with value.</param>
        /// <param name="as">The as field.</param>
        /// <param name="options">The options.</param>
        /// <returns>The fluent aggregate interface.</returns>
        public static IAggregateFluent <TNewResult> GraphLookup <TResult, TNewResult, TFrom, TConnect, TConnectFrom, TStartWith, TAsEnumerable>(
            this IAggregateFluent <TResult> aggregate,
            IMongoCollection <TFrom> from,
            Expression <Func <TFrom, TConnectFrom> > connectFromField,
            Expression <Func <TFrom, TConnect> > connectToField,
            Expression <Func <TResult, TStartWith> > startWith,
            Expression <Func <TNewResult, TAsEnumerable> > @as,
            AggregateGraphLookupOptions <TNewResult, TFrom, TConnect, TConnectFrom, TStartWith, TFrom, TAsEnumerable> options = null)
            where TAsEnumerable : IEnumerable <TFrom>
        {
            Ensure.IsNotNull(aggregate, nameof(aggregate));
            Ensure.IsNotNull(from, nameof(from));
            Ensure.IsNotNull(connectFromField, nameof(connectFromField));
            Ensure.IsNotNull(connectToField, nameof(connectToField));
            Ensure.IsNotNull(startWith, nameof(startWith));
            Ensure.IsNotNull(@as, nameof(@as));
            var connectFromFieldDefinition = new ExpressionFieldDefinition <TFrom, TConnectFrom>(connectFromField);
            var connectToFieldDefinition   = new ExpressionFieldDefinition <TFrom, TConnect>(connectToField);
            var startWithDefinition        = new ExpressionAggregateExpressionDefinition <TResult, TStartWith>(startWith, aggregate.Options.TranslationOptions);
            var asDefinition = new ExpressionFieldDefinition <TNewResult, TAsEnumerable>(@as);

            return(aggregate.GraphLookup(from, connectFromFieldDefinition, connectToFieldDefinition, startWithDefinition, asDefinition, options));
        }