public void UsingDefinition(Action <AggregateProjection <MyAggregate> > configure) { _projection = new AggregateProjection <MyAggregate>(); configure(_projection); _projection.Compile(theStore.Options); }
/** * Adds the given projection. * * @param projection the projection to add * @return this */ public IExitOperationsCollector AddProjection(IProjection projection) { if (projection.GetType().IsAssignableFrom(distinct.GetType())) { this.distinct = (Distinct)projection; //TODO: Distinct doesn't work yet log.Error("Distinct is not ready yet"); throw new NotSupportedException(); } if (projection.GetType().IsAssignableFrom(rowCountProjection.GetType())) { rowCountProjection = (RowCountProjection)projection; } if (projection.GetType().IsAssignableFrom(aggregateProjection.GetType())) { if (projection.ToString().ToLower().StartsWith("avg")) { this.avgProjection = (AggregateProjection)projection; } else { this.aggregateProjection = (AggregateProjection)projection; } } else { log.Error("Adding an unsupported Projection: " + projection.GetType().Name); throw new NotSupportedException(); } return(this); }
public void UsingDefinition <T>() where T : AggregateProjection <MyAggregate>, new() { _projection = new T(); var rules = theStore.Options.CreateGenerationRules(); rules.TypeLoadMode = TypeLoadMode.Dynamic; _projection.Compile(theStore.Options, rules); }
/// <summary> /// Register an aggregate projection that should be evaluated asynchronously /// </summary> /// <param name="projection"></param> /// <typeparam name="T"></typeparam> /// <returns>The extended storage configuration for document T</returns> public MartenRegistry.DocumentMappingExpression <T> Async <T>(AggregateProjection <T> projection) { var expression = _options.Schema.For <T>(); projection.As <IValidatedProjection>().AssertValidity(); _asyncProjections.Add(projection); return(expression); }
public void UsingDefinition(Action <AggregateProjection <MyAggregate> > configure) { _projection = new AggregateProjection <MyAggregate>(); configure(_projection); var rules = theStore.Options.CreateGenerationRules(); rules.TypeLoadMode = TypeLoadMode.Dynamic; _projection.Compile(theStore.Options, rules); }
/// <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.CompileAndAssertValidity(); All.Add(projection); }
/// <summary> /// Use a "self-aggregating" aggregate of type as an inline projection /// </summary> /// <typeparam name="T"></typeparam> /// <returns>The extended storage configuration for document T</returns> public MartenRegistry.DocumentMappingExpression <T> InlineSelfAggregate <T>() { // Make sure there's a DocumentMapping for the aggregate var expression = _options.Schema.For <T>(); var source = new AggregateProjection <T>(); source.As <IValidatedProjection>().AssertValidity(); _inlineProjections.Add(source); return(expression); }
/// <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); }
public void adding_filter_for_another_aggregate_type() { var projection = new AggregateProjection <MyAggregate>(); projection.ProjectEvent <AEvent>(a => { }); projection.FilterIncomingEventsOnStreamType(typeof(OtherAggregate)); projection.CompileAndAssertValidity(); using var store = DocumentStore.For(ConnectionSource.ConnectionString); var filters = projection.BuildFilters(store); var filter = filters.OfType <AggregateTypeFilter>().Single(); filter.AggregateType.ShouldBe(typeof(OtherAggregate)); }
internal ILiveAggregator <T> AggregatorFor <T>() where T : class { if (_liveAggregators.TryFind(typeof(T), out var aggregator)) { return((ILiveAggregator <T>)aggregator); } if (!_liveAggregateSources.TryGetValue(typeof(T), out var source)) { source = new AggregateProjection <T>(); source.As <IValidatedProjection>().AssertValidity(); } aggregator = source.As <ILiveAggregatorSource <T> >().Build(_options); _liveAggregators = _liveAggregators.AddOrUpdate(typeof(T), aggregator); return((ILiveAggregator <T>)aggregator); }
/// <summary> /// Gets total hours within any base for the specified vehicle and timespan. /// </summary> /// <param name="vehicle"></param> /// <param name="desde"></param> /// <param name="hasta"></param> /// <param name="geoRefIds"></param> /// <returns></returns> public Double GetHoursInGeofence(Int32 vehicle, DateTime desde, DateTime hasta, List <Int32> geoRefIds) { DetachedCriteria dc = GetDatamartDetachedCriteria(vehicle).FilterBeginEndBetween(desde, hasta); dc.CreateAlias("GeograficRefference", "gr", JoinType.InnerJoin).Add(Restrictions.In("gr.Id", geoRefIds)); AggregateProjection p1 = Projections.Sum <Datamart>(dm => dm.MovementHours); AggregateProjection p2 = Projections.Sum <Datamart>(dm => dm.StoppedHours); AggregateProjection p3 = Projections.Sum <Datamart>(dm => dm.NoReportHours); var p = Projections.SqlFunction(new VarArgsSQLFunction("(", "+", ")"), NHibernateUtil.Double, p1, p2, p3); ProjectionList pl = Projections.ProjectionList(); pl.Add(Projections.Alias(p, "SumOfSums")); ICriteria crit = GetDatamartCriteria(0, dc, pl, null); var result = crit.UniqueResult <Double>(); return(result); }
public void try_existing_QuestParty() { var aggregator = new AggregateProjection <QuestParty>().Build(new StoreOptions()); aggregator.ShouldNotBeNull(); }
public void UsingDefinition <T>() where T : AggregateProjection <MyAggregate>, new() { _projection = new T(); _projection.Compile(theStore.Options); }