> And if you try use IEnumerable<> instead of ICollection for your
> "disciplines"?
> 
> I've had a case when it made difference when using Contains() in where
> clause...

        In the general sense it would, but in this case I don't think it
does, because then this query:
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);

        wouldn't have worked as well (as disciplineIDs is an IEnumerable)

        so my _guess_ (but I'm not sure) is that
IEnumerable<T>.Contains(val) isn't implemented in Steve's linq provider, but
IQueryable<T>.Contains(val) is.

                FB

> 
> 
> On Fri, Aug 6, 2010 at 10:13 PM, Kevin Anderson
<[email protected]>
> wrote:
> 
> 
>       Thanks Frans.
> 
>       Sorry, I have tried so many variations it's hard to keep them
> straight.
> 
>       Here is one that works:
>                       var disciplines =
> securityContext.CurrentUser.Disciplines;
>                       var jobTypes =
> session.CreateCriteria<JobType>().List<JobType>();
>                       return new List<JobType>(from jobType in jobTypes
> where disciplines.Contains(jobType.Discipline) select jobType);
> 
>       Here is your suggestion:
> 
>                       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);
> 
> 
>       It fails with a GenericADOException was unhandled:
>       could not execute query
>       [ select jobtype0_.Id as Id13_, jobtype0_.LocationTypeId as
> Location2_13_, jobtype0_.DisciplineId as Discipli3_13_ from JobType
> jobtype0_ where jobtype0_.DisciplineId in (@p0) ]
>         Name:p1 -
>
Value:System.Linq.Enumerable+WhereSelectEnumerableIterator`2[PD.Insulation.D
> omain.Discipline,System.Guid]
>       [SQL: select jobtype0_.Id as Id13_, jobtype0_.LocationTypeId as
> Location2_13_, jobtype0_.DisciplineId as Discipli3_13_ from JobType
> jobtype0_ where jobtype0_.DisciplineId in (@p0)]
> 
>       Here is a variation on your suggestion:
>                       var discipline =
> securityContext.CurrentUser.Disciplines;
> 
>                       return new List<JobType>(from jobType in
> session.Query<JobType>()
> 
>                                                where
> discipline.Contains(jobType.Discipline)
>                                                select jobType);
> 
>       This one fails with an exception in
PolymorphicQuerySourceDetector.cs
> - GetClassName with a querySource.Type of ':'.
> 
>       I am still working on a test case.
> 
> 
>       On 10-08-06 1:18 PM, Frans Bouma wrote:
> 
> 
> 
>                         Frans,
> 
>                       Yes I did try the following but got the same
exception.
> 
>                         var disciplineIDs =
> securityContext.CurrentUser.Disciplines.Select(d
>                       => d.Id);
>                                        return session.QueryOver<JobType>()
>                                            .Where(x =>
> disciplineIDs.Contains(x.Discipline.Id))
>                                            .List();
> 
>                       that's a queryover query, I posted a linq query:
>               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);
> 
>                       which is not using QueryOver, but the linq provider.
It
> should use a
>               different codepath in the linq provider.
> 
>                               FB
> 
> 
>                       On 10-08-06 12:19 PM, Frans Bouma wrote:
> 
>                               Did you try the workaround I posted? There
are
> at least 3 kinds of
>                               Contains queries possible, and for the
person
> who's going to pick up
>                               this issue to fix it it's IMHO key that s/he
> knows what works and what
>                               doesn't so the quest to look whether it is
> implemented is easier ;)
> 
>                                       FB
> 
> 
>                                       :) Yes, I got it. I was working on
it the
> whole time but you kept
>                                       asking questions.<g>
> 
>                                       On 10-08-06 11:19 AM, Fabio Maulo
wrote:
> 
> 
>                                                       To be frankly ?
(again)
>                                                       You can create a
failing
> test and open a new JIRA ticket,
> 
>                               then
> 
>                                       we can check which is the problem.
(<==
> time 3)
> 
> 
>                                               Ups sorry, it was the time 4
> 
> 
>                                               --
>                                               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.
> 
> 
> 
>                                       --
>                                       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.
> 
> 
>       --
>       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.

Reply via email to