sql server - Why my Linqued query is not giving me proper result? -
i have sql query gives me proper result i.e names of employee sorted z using order clause
select distinct(empntlogin),employee attendance createdate>='2016-01-01' order empntlogin
when converted same query in linq,i getting right result order clause not working. here linqued query
var query = (from attendance in db.attendances orderby attendance.empntlogin attendance.createdate.value.year >= 2016 select new { attendance.employee, attendance.empntlogin }).distinct();
in linq query, distinct applied after orderby
, therefore order discarded.
apply orderby after call distinct
var query = (from attendance in db.attendances attendance.createdate.value.year >= 2016 select new { attendance.employee, attendance.empntlogin }).distinct().orderby(att => att.empntlogin);
Comments
Post a Comment