I know you can execute a Linq to NHibernate query as a future by calling the .ToFuture<>() extension method. However I’m not loading mapped entities but directly loading the data into DTO’s. So you get something like:
var results = (from e in session.Query<Entity>()
where e.Reference.Id == someId
orderby e.Name
select new Dto
{
Id = e.Id,
Name = e.Name,
// ...
}).ToFuture<Dto>();
This doesn’t work as I want it (I dare to say expected). I now get an error: The value "System.Object[]" is not of type "Entity" and cannot be used in this generic collection. If I remove .ToFuture() it does work, but the query is not batched.
I know you can do this with the QueryOver API, I just like Linq to NH better because it’s so much cleaner code.
It looks like a bug. If you can create a simple reproduction test case, please enter a new issue at https://nhibernate.jira.com/.
Before doing that, please verify if you’re using the latest version (3.2 at the time), as there was already a similar defect that was fixed in this release.