This question is locked. New answers and comments are not allowed.
Hi,
In sql I can get records by a collection of ids like this
How can I do this in OQL or linq?
Thanks
In sql I can get records by a collection of ids like this
SELECT resourcelibrary.* from resourcelibrary where ResourceID in ( 1,5,7,9,32) |
How can I do this in OQL or linq?
Thanks
4 Answers, 1 is accepted
0
Accepted
Hi Paul,
here is a sample code snippet for achieving your goal using LINQ:
Note that the Category table from Northwind database is used in the above example.
Regards,
PetarP
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
here is a sample code snippet for achieving your goal using LINQ:
IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope(); |
List<int> myList = new List<int>() { 1, 2, 3, 4 }; |
var result = from c in scope.Extent<Category>() |
where myList.Contains(c.CategoryID) |
select c; |
foreach (Category ct in result) |
{ |
Console.WriteLine(ct.CategoryID); |
} |
Regards,
PetarP
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Paul
Top achievements
Rank 1
answered on 21 May 2009, 01:53 PM
Hi Petar,
Thats perfect and works great thanks.
Regards,
Paul.
Thats perfect and works great thanks.
Regards,
Paul.
0
Devanand Chahal
Top achievements
Rank 2
answered on 26 Aug 2010, 10:11 AM
Hi Peter,
If I need to build a expression for IN clause dynamically using Expression tree, Then how can I acheive this.
Thanks
Devanand
0
Hi Devanand Chahal,
Petar
the Telerik team
I believe that you will find the following topic useful as it discuss how to use expression trees to build dynamic queries.
All the best,Petar
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items