The official RavenDB v4 documentation suggests to use IRavenQueryable<T>.Select()
method for getting custom fields in the result set. It works well even for computed fields, e.g.
session.Query<Order>()
.Select(x => new { Total = x.Lines.Sum(l => l.PricePerUnit * l.Quantity) })
Question: Is there a way to have computed fields in the result set (like above) when using IDocumentQuery<T>
or IAsyncDocumentQuery<T>
instance instead of IRavenQueryable<T>
?
The documentation says that the Query
requests get converted into IDocumentQuery<T>
under the hood. However, the closest method for narrowing down the output field set is SelectFields<T>()
, which doesn't have an option for having calculated fields in the result set.
P.S. The docs say that Query
is always translated into the DocumentQuery
object. However, I couldn't find in the code how it's been implemented (though I guess it's done via IQueryable.Expression).
Maybe RQL is a way to go now...