This question is locked. New answers and comments are not allowed.

sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve
asked on 25 Sep 2010, 03:35 AM
If I have a List<int> of product IDs, can OA somehow just return me back those items instead if me having to loop through? Is there like a .Contains that i can use? Or do I have to manually get the items one at a time and add them to a local collection?
5 Answers, 1 is accepted
0

IT-Als
Top achievements
Rank 1
answered on 25 Sep 2010, 08:33 AM
Hi Steve,
You can use the generic version of QueryResult<int> and then use the ToList() method on the result instance... it will hand you a (generic) list of int.
Does it solve your problem?
/Henrik
You can use the generic version of QueryResult<int> and then use the ToList() method on the result instance... it will hand you a (generic) list of int.
Does it solve your problem?
/Henrik
0

sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 25 Sep 2010, 03:52 PM
Hey there Henrik,
You know I posted this REALLY late, and reading it back now, it makes no sense :)
The productID list would store (for example) product IDs 1, 5, 8.
So how would I query my model to get those 3 in a single query instead of having to call out three times to build me own list
Sorry about the confusion :)
Steve
You know I posted this REALLY late, and reading it back now, it makes no sense :)
The productID list would store (for example) product IDs 1, 5, 8.
So how would I query my model to get those 3 in a single query instead of having to call out three times to build me own list
Sorry about the confusion :)
Steve
0
Accepted

IT-Als
Top achievements
Rank 1
answered on 27 Sep 2010, 07:43 AM
Hi Steve,
That's ok - been working late, too, lately so I know the feeling.
Anyway, I am not aware of any query construct that can hand you what you need besides the ToList() method. Those product ids, do you collect them from the same entity?
Can you show me in OQL/LINQ/SQL what you are trying to achive and how you select those product id values and from where..
Regards
Henrik
That's ok - been working late, too, lately so I know the feeling.
Anyway, I am not aware of any query construct that can hand you what you need besides the ToList() method. Those product ids, do you collect them from the same entity?
Can you show me in OQL/LINQ/SQL what you are trying to achive and how you select those product id values and from where..
Regards
Henrik
0
Accepted
Hi Steve,
You can use the following query to achieve this:
Hope that helps.
Greetings,
Damyan Bogoev
the Telerik team
You can use the following query to achieve this:
...
List<
int
> productIdList =
new
List<
int
> { 1, 5, 8 };
IQueryable<Product> filteredProducts = context.Products.Where(p => productIdList.Contains(p.ProductID));
...
Hope that helps.
Greetings,
Damyan Bogoev
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
0

IT-Als
Top achievements
Rank 1
answered on 29 Sep 2010, 07:58 AM
Of cause, Damyan...
Thanks for adding this snippet to the knowledge bank in my brain :-)
/Henrik
Thanks for adding this snippet to the knowledge bank in my brain :-)
/Henrik