Esempio n. 1
0
        /// <summary>
        /// Aggregate the events in this query to the type T
        /// </summary>
        /// <param name="queryable"></param>
        /// <param name="state"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T AggregateTo <T>(this IMartenQueryable <IEvent> queryable, T state = null) where T : class
        {
            var events = queryable.ToList();

            if (!events.Any())
            {
                return(null);
            }

            var session    = queryable.As <MartenLinqQueryable <IEvent> >().Session;
            var aggregator = session.Options.Projections.AggregatorFor <T>();

            var aggregate = aggregator.Build(queryable.ToList(), (IQuerySession)session, state);

            return(aggregate);
        }
Esempio n. 2
0
        internal Task <IReadOnlyList <T> > Query <T>(IMartenQueryable <T> queryable)
        {
            var handler = queryable.As <MartenLinqQueryable <T> >().BuildHandler <IReadOnlyList <T> >();

            return(AddItem(handler));
        }