Ejemplo n.º 1
0
        protected virtual PipelineDefinition <TInput, Subscriber <ObjectId> > AddSubscribersProjectionAndLimitStage <TInput>(
            PipelineDefinition <TInput, BsonDocument> pipeline, SubscribersRangeParameters <ObjectId> subscribersRange)
        {
            var projection = Builders <TDeliveryType> .Projection
                             .Exclude(x => x.SubscriberDeliveryTypeSettingsId)
                             .Include(x => x.SubscriberId)
                             .Include(x => x.DeliveryType)
                             .Include(x => x.Address)
                             .Include(x => x.TimeZoneId)
                             .Include(x => x.Language);

            var pipelineTyped = pipeline
                                .As <TInput, BsonDocument, TDeliveryType>()
                                .Project(projection)
                                .As <TInput, BsonDocument, Subscriber <ObjectId> >();

            if (subscribersRange.Limit != null)
            {
                pipelineTyped = pipelineTyped.Limit(subscribersRange.Limit.Value);
            }

            return(pipelineTyped);
        }