I have a list defining the identifiers of several objects in my database. I want to get a set of objects, all from one table that have these identifiers, and keep them in that exact order, and I want it to be executed as a single database query (and not "N").
For example, I have a list of identifiers {5, 3, 6, 9}, and I want to return a list of Customer objects with these identifiers and keep them in order {Customer (5, 'Bob'), Client (3, "JimBo") , Client (6, "Joe"), Client (9, "Jack")}.
The amount of data is quite small, and I do not mind re-sorting it after a database query. I could do all this in about 15 lines of clean code (including manual re-sorting), but I feel there should be a one- or two-line LINQ query to EF, which should make it easy.
source share