I have an array of string that needs to be search on a context.
List<string> nameList
and I have a context to be searched on
context.Name
I have my code here:
List<Guid> nameIds= context.Name
.Where(n => nameList.Contains(n.Description)
.Select(n=> n.NameId)
.ToList();
I can get the ID of my names, but I want it to be ordered by the nameList
, not by the context itself.
For example. The names on my database are [Ben, Maria, Liza] with [0, 1, 2] id respectively. And my nameList
is [Liza, Maria] orderly. The nameIds
will be [1,2] because it is ordered by the context. I want it to be ordered by nameList
; [2,1]