NH3 has is system to recognize methods and translate it and it is extensible
http://fabiomaulo.blogspot.com/2010/07/nhibernate-linq-provider-extension.html

<http://fabiomaulo.blogspot.com/2010/07/nhibernate-linq-provider-extension.html>With
a test-case we will analyze what the problem is.

On Fri, Aug 6, 2010 at 1:40 PM, Frans Bouma <[email protected]> wrote:

> > btw... Queryable.Contains, Enumerable.Contains, ICollection<>.Contains
> are
> > supported.
> > If you have a failing test we can check your case.
>
>         Can't this be a compiler thingy? I mean: ICollection<T>.Contains is
> not an extension method, but IQueryable<T>.Contains() is, which means that
> ICollection<T>.Contains is chosen above IQueryable<T>.Contains(). As he
> uses
> an in-memory collection (as I don't see securityContext to be a member of
> the query, so it's an in-memory element), ICollection<T>.Contains is chosen
> I think, which means it's convertible to SQL only if you have a comparison
> handler which takes a collection of objects (the Disciplines), checks the
> element to compare with (jobType.Discipline, entity), and creates an IN
> query based on the pk field values in the collection of objects. This takes
> custom code, other than when you'd do:
>
> var q = from c in session.Query<Customer>()
>         where c.Orders.Contains(someOrder)
>        select c;
>
> as that's the IQueryable Contains.
>
>        IIRC, EF and l2s also don't support this. it's doable but takes a
> custom code path. It very well can be Steve didn't implement this in his
> linq provider, as it's more or less an edge case.
>
>        It's also different from:
> var q = from c in session.Query<Customer>()
>         where new string[] { "USA", "Argentina"}.Contains(c.Country)
>        select c;
>
> as with this query, you don't have to do a compare on entity (so you don't
> have to look up which PK fields you have on the entity to compare and
> create
> a list of values from the collection from the objects in the collection by
> reading the properties with the same names), but just with a field.
>
>        So not easy to fix I think, but also not a big issue as it is a bit
> of an edge case.
>
>        To Kevin,
>
> If you do:
> var disciplineIDs =
> securityContext.CurrentUser.Disciplines.Select(d=>d.ID);
> return new List<JobType>(
>   from jobType in session.Query<JobType>()
>    where disciplineIDs.Contains(jobType.Discipline.Id)
>   select jobType);
>
>        does that work? It should take a different code path.
>
>                FB
>
> >
> >
> > On Fri, Aug 6, 2010 at 1:13 PM, Kevin Anderson
> <[email protected]>
> > wrote:
> >
> >
> >       I am sorry Fabio, I am not sure I understand. Are you saying that a
> > change needs to be made in the nh3 trunk code to handle this case that
> was
> > previously working?
> >
> >       I don't have a test case, did you want a unit test or stand alone
> > type test case?
> >
> >
> >       On 10-08-06 10:01 AM, Fabio Maulo wrote:
> >
> >               contains should be implemented in trunk.
> >               Have you a test case?
> >
> >
> >               On Fri, Aug 6, 2010 at 12:42 PM, Kevin Anderson
> > <[email protected]> wrote:
> >
> >
> >                       Yes, I have code that is now broken and I am not
> sure
> > why:
> >
> >                                      return new List<JobType>(
> >                                           from jobType in
> > session.Query<JobType>()
> >                                           where
> >
> >
> securityContext.CurrentUser.Disciplines.Contains(jobType.Discipline)
> >                                           select jobType);
> >
> >                       This code was working with nh 2.1.2GA but now I get
> > "Specified method
> >                       is not supported".
> >
> >                       When I rewrote it to use QueryOver instead:
> >
> >                                      return session.QueryOver<JobType>()
> >                                          .Where(x =>
> >
> >       securityContext.CurrentUser.Disciplines.Contains(x.Discipline))
> >                                          .List();
> >
> >                       This way I get a more descriptive message:
> >
> >                       Unrecognised method call:
> >
> >
> System.Collections.Generic.ICollection`1[[PD.Insulation.Domain.Discip
> > line,
> >                       PD.Insulation.Domain, Version=0.0.0.0,
> Culture=neutral,
> >                       PublicKeyToken=null]]:Boolean
> >                       Contains(PD.Insulation.Domain.Discipline)
> >
> >
> >
> >
> >
> >                       On Fri, Aug 6, 2010 at 8:46 AM, James Gregory
> > <[email protected]> wrote:
> >                       > Is there anything in particular you're having
> trouble
> > with?
> >                       >
> >                       > On Aug 6, 3:24 pm, Kev
> <[email protected]>
> > wrote:
> >                       >> Now that nh3 has released a new/updated linq
> > provider, I was wondering
> >                       >> if there are a list of differences between this
> > version (nh3 linq) and
> >                       >> nhibernate.linq 1.0? I am trying to change to
> nh3
> > but there is
> >                       >> obviously more involved than changing
> session.linq
> > to session.Query.
> >                       >>
> >                       >> A pointer to some documentation would be
> > fantastic...
> >                       >>
> >                       >> TIA
> >                       >
> >                       > --
> >                       > 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]<nhusers%[email protected]>
> > <mailto:nhusers%[email protected]<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]<nhusers%[email protected]>
> > <mailto:nhusers%[email protected]<nhusers%[email protected]>>
> .
> >                       For more options, visit this group at
> > http://groups.google.com/group/nhusers?hl=en.
> >
> >
> >
> >
> >
> >
> >               --
> >               Fabio Maulo
> >
> >
> >               --
> >
> >               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]<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]<nhusers%[email protected]>
> > <mailto:nhusers%[email protected]<nhusers%[email protected]>>
> .
> >       For more options, visit this group at
> > http://groups.google.com/group/nhusers?hl=en.
> >
> >
> >
> >
> >
> > --
> > Fabio Maulo
> >
> >
> >
> > --
> > 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]<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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>


-- 
Fabio Maulo

-- 
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.

Reply via email to