Reputation: 557
We have some code written which depends on working with the IQueryable
instances, so I suppose we are stuck with having to use ISession.Query<>()
.
In one particular case I would like to only partially hydrate the DBOs and exclude certain columns from the SELECT statement which NHibernate will generate.
Is it possible to achieve that while using Query<>
?
Alternatively, is it possible to somehow go from ICriteria
to IQueryable
? (I think for ICriteria
it is possible to achieve what I need by using Projections?)
Upvotes: 0
Views: 1353
Reputation: 123861
Projections are supported in IQueryable
as well. Syntax should be like this:
var query = session.Query<Employee>();
var list = query.Select(s => new Employee
{
FirstName = s.FirstName,
LastName = s.LastName,
...
})
.ToList();
The new Employee could be even some DTO...
Some basic info about QueryOver
projection API:
Upvotes: 1