I have a color table that contains values, and I have a string of IDs that are the IDs of this table.I want to return only values whose ID is in the string of IDs
string Ids :
1,3,5
I want to receive the values whose IDs are 1, 3, and 5 as a list ?
With EF Core you have to use Contains
:
var ids = stringIds.Split(',')
.Select(s => int.Parse(s))
.ToArray();
var colors = db.Colors
.Where(x => ids.Contains(x.Id))
.ToList();