I'm struggling with this Linq
query which queries the database.
var roles = _context.Schools
.Select(x =>
new SelectListItem
{
Value = x.SchoolId.ToString(),
Text = x.SchoolNamePostCode
});
My query currently gets the whole rows of Schools into a SelectListItem
. However what I am trying to do is add in a Where clause, which contains an array of string value IDs.
string[] AssociatedSchoolsArray = AssociatedSchoolIDs.Split(",");
The variable AssociatedSchoolsArray
contains an array, for example, "1","3"
So in my original Linq
query, I want to filter the SelectListItem
for SchoolIds
1 and 3 only
how can I achieve this?
Many thanks