I have to list all "shift" data to be assigned to an "employee" but shift data must not be included if it is already existing in employee's data. Let's see the image sample.
This query solves the problem. I found this here:
select * from shift where not exists (select 1 from employeeshift where shift.shiftid = employeeshift.shiftid and employeeshift.empid = 57);
Let's see the result:
Now my question is, how could I make this in linQ ? I'm using entity framework.
Hope someone could help. Thanks a lot!!!
from s in context.shift where !context.employeeshift.Any(es=>(es.shiftid==s.shiftid)&&(es.empid==57)) select s;
Hope this helps
The outcome sql will be different but the result should be the same:
var shifts = Shifts.Where(s => !EmployeeShifts.Where(es => es.ShiftID == s.ShiftID).Any());