score:3

Accepted answer
//asuming your db has these fields: db.shifts, db.operatorshifts
//and model is the current operator

var existingshifts = (from os in db.operatorshifts
                where os.operatorid == model.id
                select os).tolist();

ienumerable<guid> newshiftids = ?; //don't now how your selected shift ids got post back, figure it out yourself

var shiftstoremove = existingshifts.where(e => newshiftids.all(id => e.id != id)).tolist();
var shiftidstoappend = newshiftids.where(id => exising.all(e => e.id != id)).tolist();

foreach(var shift in shiftstoremove)
{
    db.operatorshifts.remove(shift);
}

foreach(var shiftid in shiftidstoappend)
{
    db.operatorshifts.add(new operatorshift{
        operatorid = model.id,
        shiftid = shiftid
    });
}

Related Query

More Query from same tag