Where...In Clause

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
robpi
Posts: 2
Joined: Mon 30 Mar 2009 19:37

Where...In Clause

Post by robpi » Mon 30 Mar 2009 19:50

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.

rick.duarte
Posts: 35
Joined: Fri 23 Jan 2009 23:07
Location: Rio de Janeiro, Brazil

Post by rick.duarte » Tue 31 Mar 2009 13:01

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;

robpi
Posts: 2
Joined: Mon 30 Mar 2009 19:37

Post by robpi » Tue 31 Mar 2009 14:04

Thanks for the reply, however when I try an int array instead of a generic List I get the same exception. Any other ideas?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 31 Mar 2009 14:43

Thank you for the report, we have reproduced the problem.
I will let you know as soon as it is fixed.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 10 Apr 2009 11:11

The problem is fixed in dotConnect for MySQL Beta 2.

Post Reply