Also, exposing IQueryable outside the repositories is not really a good
idea, if you want to follow Evans' DDD approach: the query isn't executed
when you call the method. This means that the repositories aren't really
repositories but rather query factories.
FB
> OK, that's different.
> You might be able to accomplish this using the new extensible Linq
> generators.
> Check
>
https://nhibernate.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/s
> rc/NHibernate.Test/Linq/CustomExtensionsExample.cs
>
>
<https://nhibernate.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/
> src/NHibernate.Test/Linq/CustomExtensionsExample.cs> However, having a
> Distinct in your main repository method looks like a dirty (and somewhat
> expensive) way to fix a few misbehaving queries that could be fixed
> individually while adding an unnecesary cost to all other queries.
> It's like an empty catch{} statement, but worse.
>
> Diego
>
>
>
> On Sun, Aug 29, 2010 at 18:08, MichaelK <[email protected]> wrote:
>
>
> I will give that a try, but maybe I should be more explicit as to
> what
> I had before and what IDEALLY I was looking for.
>
> In NH2 with linq provider I exposed from my repository...
>
> IQueryable<T> Query
> {
> var query = Session.Linq<T>();
> query.QueryOptions.RegisterCustomAction(x =>
> x.SetResultTransformer(new DistinctRootEntityResultTransformer()));
> return query;
> }
>
> 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. I still needed to be
> careful regarding large results sets being returned but it was nice
> knowing you would always get the distinct results.
>
> Now in NH3 I have this, but would like to still apply the Distinct
> transformer if possible.
>
> IQueryable<T> Query
> {
> return Session.Query<T>();
>
> }
>
>
>
> On Aug 29, 1:00 pm, Diego Mijelshon <[email protected]> wrote:
> > queryable.AsEnumerable().Distinct().ToList()
> >
> > will get you the same results as
> >
> >
> query.SetResultTransformer(Transformers.DistinctRootEntity).List()
> >
> > Diego
> >
>
> > On Sun, Aug 29, 2010 at 13:43, MichaelK <[email protected]> wrote:
> > > I don't think Distinct() works for what I am talking about. That
> seems
> > > to add the DISTINCT keyword to the SQL command, but using the
> > > DistinctRootEntityResultTransformer() used to take that sql
> result and
> > > when hydrating the entities apply the transformer providing only
> > > Distinct entries. I see on the IQuery interface there is a
> > > SetTransformer method. Can I get from IQuery to IQueryable?
> >
> > > On Aug 26, 12:23 pm, Diego Mijelshon <[email protected]>
> wrote:
> > > > .Distinct() should do...
> >
> > > > Diego
> >
> > > > On Thu, Aug 26, 2010 at 13:14, MichaelK <[email protected]>
> wrote:
> > > > > Hello,
> >
> > > > > I just upgraded to NH 3.0.0 Alpha 2 where previously I was
> using NH
> > > > > 2.2.4 with Linq addin. One feature I had in my old
repository
> was a
> > > > > 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 so its
> > > > > always there?
> >
> > > > > --
> > > > > You received this message because you are subscribed to the
> Google
> > > Groups
> > > > > "nhusers" group.
> > > > > To post to this group, send email to
> [email protected].
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]
> <mailto:nhusers%[email protected]>
> <nhusers%[email protected]
> <mailto:nhusers%[email protected]> >
>
> > > <nhusers%[email protected]
> <mailto:nhusers%[email protected]>
> <nhusers%[email protected]
> <mailto:nhusers%[email protected]> >
>
> >
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/nhusers?hl=en.
> >
> > > --
> > > You received this message because you are subscribed to the
> Google Groups
> > > "nhusers" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]
> <mailto:nhusers%[email protected]>
> <nhusers%[email protected]
> <mailto:nhusers%[email protected]> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=en.
>
> --
> You received this message because you are subscribed to the Google
> Groups "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]
> <mailto:nhusers%[email protected]> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.