/// <summary> /// Register an aggregate projection that should be evaluated inline /// </summary> /// <param name="projection"></param> /// <typeparam name="T"></typeparam> /// <param name="lifecycle">Optionally override the ProjectionLifecycle</param> /// <returns>The extended storage configuration for document T</returns> public void Add <T>(AggregateProjection <T> projection, ProjectionLifecycle?lifecycle = null) { if (lifecycle.HasValue) { projection.Lifecycle = lifecycle.Value; } projection.AssertValidity(); All.Add(projection); }
/// <summary> /// Register an aggregate projection that should be evaluated inline /// </summary> /// <param name="projection"></param> /// <typeparam name="T"></typeparam> /// <param name="lifecycle">Optionally override the ProjectionLifecycle</param> /// <returns>The extended storage configuration for document T</returns> public MartenRegistry.DocumentMappingExpression <T> Add <T>(AggregateProjection <T> projection, ProjectionLifecycle?lifecycle = null) { var expression = _options.Schema.For <T>(); if (lifecycle.HasValue) { projection.Lifecycle = lifecycle.Value; } projection.AssertValidity(); All.Add(projection); return(expression); }
/// <summary> /// Use a "self-aggregating" aggregate of type. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="lifecycle">Override the aggregate lifecycle. The default is Inline</param> /// <returns>The extended storage configuration for document T</returns> public MartenRegistry.DocumentMappingExpression <T> SelfAggregate <T>(ProjectionLifecycle?lifecycle = null) { // Make sure there's a DocumentMapping for the aggregate var expression = _options.Schema.For <T>(); var source = new AggregateProjection <T>() { Lifecycle = lifecycle ?? ProjectionLifecycle.Inline }; source.AssertValidity(); All.Add(source); return(expression); }