How do I get results from a link query in the order of IDs that I provide?
Posted
by Keltex
on Stack Overflow
See other posts from Stack Overflow
or by Keltex
Published on 2010-05-26T22:37:23Z
Indexed on
2010/05/26
22:41 UTC
Read the original article
Hit count: 309
I'm looking to get query results back from Linq in the order that I pass IDs to the query. So it would look something like this:
var IDs = new int [] { 5, 20, 10 }
var items = from mytable in db.MyTable
where IDs.Contains(mytable.mytableID)
orderby // not sure what to do here
select mytable;
I'm hoping to get items in the order of IDs
(5, 20, 10).
(Note this is similar to this question, but I would like to do it in Linq instead of SQL)
© Stack Overflow or respective owner