Example #1
0
        public static ElasticMultiSearchRequest GenerateElasticSearchRequest(QueryModel queryModel)
        {
            var visitor = new ProjectionQueryModelVisitor();

            visitor.VisitQueryModel(queryModel);
            return(visitor.GetElasticSearchRequest());
        }
Example #2
0
        /// <summary>
        /// Executes a query with a collection result.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="queryModel">The query model.</param>
        /// <returns></returns>
        public IEnumerable <T> ExecuteCollection <T>(QueryModel queryModel)
        {
            var elasticSearchRequest = ProjectionQueryModelVisitor.GenerateElasticSearchRequest(queryModel);

            List <IEvent> events = projectionsApi
                                   .MultiSearch(elasticSearchRequest)
                                   .OrderBy(x => x.Revision).ThenBy(x => x.EventPosition).ThenBy(x => x.Timestamp)
                                   .Select(x => x.Event).ToList();
            dynamic handler = (dynamic)FastActivator.CreateInstance(typeof(T));

            foreach (var item in events)
            {
                handler.Handle((dynamic)item);
            }
            yield return((T)handler);
        }
 public static ElasticMultiSearchRequest GenerateElasticSearchRequest(QueryModel queryModel)
 {
     var visitor = new ProjectionQueryModelVisitor();
     visitor.VisitQueryModel(queryModel);
     return visitor.GetElasticSearchRequest();
 }