c# - Where clause causing cannot compare elements error -
i have 2 tables, doctors , doctorshifts, relation between 2 table one(doctor) many(doctorshifts).
in doctorshifts saved days of week each doctor work on.
what need display list of doctors work today, tried following expression not work :
iqueryable<doctor> todaydoctorsquery = _context.doctors.where(s => s.doctorshifts.where(s2 => s2.dayoftheweek == _todaynumber) != null);
the error :
cannot compare elements of type 'system.collections.generic.ienumerable`1[[medcare_software.edm.doctorshift, medcare-software, version=1.0.0.0, culture=neutral, publickeytoken=null]]'. primitive types, enumeration types , entity types supported."}
how can list of doctor works today?
the inner clause returns ienumerable<doctorshift>
can't compared null.
anyway, you're better off using any
in:
var todaydoctorsquery = _context.doctors.where( s=> s.doctorshifts.any(s2 => s2.dayoftheweek == _todaynumber));
and make sure dayoftheweek
, _todaynumber
same type.
Comments
Post a Comment