private IFutureValue <T> ExecuteQueryTreeFutureValue <T>(Expression queryExpression) { var tree = new QueryRelationTree(); IFutureValue <T> result = null; foreach (var path in IncludePaths) { tree.AddNode(path); } var leafs = tree.GetLeafs(); leafs.Sort(); var expressions = leafs.Aggregate(new ExpressionInfo(queryExpression), FetchFromPath).GetExpressions(); var i = 0; foreach (var expression in expressions) { if (i == 0) { result = _queryProvider.ExecuteFutureValue <T>(expression); } else { _queryProvider.ExecuteFuture <T>(expression); } i++; } return(result); }
private List <Expression> GetExpressions(Expression queryExpression) { IClassMetadata meta; var metas = Session.Factory.GetAllClassMetadata() .Select(o => o.Value) .Where(o => Type.IsAssignableFrom(o.MappedClass)) .ToList(); if (!metas.Any()) { throw new HibernateException($"Metadata for type '{Type}' was not found"); } if (metas.Count > 1) { meta = metas.FirstOrDefault(o => o.MappedClass == Type); if (meta == null) { throw new HibernateException( $"Unable to find the the correct candidate for type '{Type}'. Candidates: {string.Join(", ", metas.Select(o => o.MappedClass))}"); } } else { meta = metas.First(); } var tree = new QueryRelationTree(); foreach (var path in IncludePaths) { tree.AddNode(path); } var leafs = tree.GetLeafs(); leafs.Sort(); return(leafs.Aggregate(new ExpressionInfo(queryExpression, meta), FetchFromPath).GetExpressions()); }