I have an existing set of items in a database where a MultiSelectList of Id’s allows Shifts to be added to an Operator.
Currently, an Operator has 3 Shifts assigned. This is now edited on the View to remove 1 Shift from the 3.
What is the best way to go through the existing set of items and determine which of the 3 to remove that isn’t found in the list of selected items.
I know the easiest method would be to remove all items in the database for the Operator and then insert the values from the MultiSelectList but thought there might be a way to use LINQ to select from existing where not in the list of Id’s
var existing = (from os in db.OperatorShifts
where os.OperatorId == model.Id
select os);
public List<Guid?> Shifts { get; set; }
public MultiSelectList AvailableShifts { get; set; }
model.Shifts
1 Answer