score:1

Accepted answer

I would just do it outside of the SQL query. There's really no benefit to getting it done on the SQL Server in this case.

var items = (from mytable in db.MyTable
             where IDs.Contains(mytable.mytableID)
             select mytable)
            .ToArray()
            .OrderBy(x => Array.IndexOf(ids, x.mytableID));

score:1

This should work with LINQ-to-objects; I'm not sure if it does with LINQ-to-SQL though:

var ids = new int [] { 5, 20, 10 };

var result = from item in items
             where Array.IndexOf(ids, item.Id) >= 0
             orderby Array.IndexOf(ids, item.Id)
             select item;

Related Query