Page 1 of 1

Where...In Clause

Posted: Mon 30 Mar 2009 19:50
by robpi
I have a problem when trying to execute a Linq query with a "Where...In" clause. The exception message is "values.Count". Here is a simple example of what I'm trying to execute.

Code: Select all

List userIds = new List() { 1, 2, 3 };
var query = from u in context.Users
                  where userIds.Contains(u.id)
                  select u.FirstName;
Thank you very much for you help.

Posted: Tue 31 Mar 2009 13:01
by rick.duarte
Try this:

Code: Select all

int[] userIds = new int[]{ 1, 2, 3 }; 
var query = from u in context.Users 
                  where userIds.Contains(u.id) 
                  select u.FirstName; 
or

Code: Select all

var query = from u in context.Users 
                  where new int[]{ 1, 2, 3 }.Contains(u.id) 
                  select u.FirstName;

Posted: Tue 31 Mar 2009 14:04
by robpi
Thanks for the reply, however when I try an int array instead of a generic List I get the same exception. Any other ideas?

Posted: Tue 31 Mar 2009 14:43
by AndreyR
Thank you for the report, we have reproduced the problem.
I will let you know as soon as it is fixed.

Posted: Fri 10 Apr 2009 11:11
by AndreyR
The problem is fixed in dotConnect for MySQL Beta 2.