DistinctRootEntityResultTransformer not available in NHibernate Linq

Description

I have the same problem as a user describes here: http://groups.google.com/group/nhusers/browse_thread/thread/6a4c233931dc5eea

I just upgraded to NH 3.2.0GA where previously I was using NH2.2.4 with Linq addin. One feature I had in my old repository was SetResultTransformer(new DistinctRootEntityResultTransformer()) to ensure unique records when I eagerly fetched values using left joins. My Repository exposes IQueryable<T>. In NH 3 I am using Session.Query<T>, but how can I add a ResultTransformer to that?

In NH2 with linq provider I could write

var query = Session.Linq<T>().QueryOptions.RegisterCustomAction(x => x.SetResultTransformer(new DistinctRootEntityResultTransformer()));

That always ensured that the Distinct Results were always applied. This was useful when eagerly fetching a few collections at once (left joins) which produced a Carteasian product.
How could that be done in NH3 with using IQueryable? I know that it could be done with ICriteria but I want to use Linq.

Distinct s not working for this.

Thanks for your help.

Environment

None

Activity

Show:

Ricardo Peres 
December 2, 2014 at 10:34 AM

Criteria makes sense for dynamic queries, instead of concatenating HQL strings, and is useful, but not QueryOver: it is just an hybrid implementation of LINQ and something else, that doesn't really behave like LINQ nor like anything else.
I see this a part of an effort to unify all NH querying APIs. But I don't give it too much importance.

Alex Zaytsev 
December 2, 2014 at 10:31 AM

Ok, can you provide an example where this will make a) code cleaner; b) make life easier?

Alex Zaytsev 
December 2, 2014 at 10:29 AM

If it depends on me.. I would like to deprecate criteria and queryover. But only when we will have perfect implementation of Linq Provider.

Ricardo Peres 
December 2, 2014 at 10:19 AM

Can you provide a real life example where QueryOver is necessary?

Alex Zaytsev 
December 2, 2014 at 10:15 AM
(edited)

can you provide a real life example where this is necessary?

Won't Fix

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created October 22, 2012 at 2:24 PM
Updated December 2, 2014 at 10:34 AM
Resolved December 2, 2014 at 10:12 AM
Who's Looking?