예제 #1
0
        public InitializeLiveAggregateFrame(Type aggregateType, Type idType, CallCreateAggregateFrame create) : base(true)
        {
            _aggregateType = aggregateType;
            _idType        = idType;
            _create        = create;
            _create.FirstEventExpression = "stream.Events.First()";

            Aggregate = new Variable(aggregateType, this);

            var load = typeof(IQuerySession)
                       .GetMethods()
                       .Single(x => x.Name == "LoadAsync" && x.GetParameters().First().ParameterType == idType)
                       .MakeGenericMethod(aggregateType);

            _loadMethod = new MethodCall(typeof(IDocumentSession), load);
            _loadMethod.AssignResultTo(Aggregate);
        }