I have a list of IDs and I need to retrieve entities from a database in exact same order, that IDs in the list.
Such query will return wrong order:
List<Guid> listOfIds = targetIds;
var result = await dbContext
.TargetEnities
.Where(x => listOfIds.Contains(x.Id))
.ToListAsync();
I see a way to make requests in a loop and union result, but it looks too expensive.
How to solve that?