This is a migrated thread and some comments may be shown as answers.

How to write query with IN operator

2 Answers 314 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ratndeep
Top achievements
Rank 1
Ratndeep asked on 07 Jan 2010, 05:35 AM
Hi ,
I have  a table Role with fields RoleId and Name.I have to write a query something like that
select * from Role where RoleId in (1,2,3). but somehow not able to  get the equivalent of in operator in OA Linq.
Please Help 

where  could i find some join samples in the Linq for  Q3 release on telerik site .

Thanks
Ratndeep

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander
Telerik team
answered on 07 Jan 2010, 01:00 PM
Hi Ratndeep,

You can use the Contains() method of a List collection as follows:
List<int> ids = new List<int>() { 1, 2, 3 };
 
var result = (from x in scope.Extent<Role>()
        where ids.Contains(x.RoleId)
        select x).ToList();

You could find some Linq join samples in our C# Linq Examples application which is distributed with the product. There should be a shortcut in your start menu under Telerik -> OpenAccess ORM.
Hope that helps.

Sincerely yours,
Alexander
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ratndeep
Top achievements
Rank 1
answered on 07 Jan 2010, 02:56 PM
Thanks Alexander.It worked.You guys are great !
Tags
LINQ (LINQ specific questions)
Asked by
Ratndeep
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Ratndeep
Top achievements
Rank 1
Share this question
or