I have the following view:-
CREATE VIEW tbl_adjudicator_result_view
AS
SELECT a.adjudicator_id, sar.section_adjudicator_role_id, s.section_id, sdr.section_dance_
The point is: you're grouping your data in the LINQ query - and you'll always get at least one group.
That group's Count
may be 0 - but the count of groups will be 1.
You're not doing the same thing in the LINQ query as in the SQL. COUNT(result_id)
does not count distinct values of result_id
- it counts non-null values.
Try this instead:
Count = grp.Select(p => p.result_id).Where(x => x != null).Count()