LINQ count query returns a 1 instead of a 0

前端 未结 2 1104
无人及你
无人及你 2021-01-22 01:57

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_         


        
2条回答
  •  [愿得一人]
    2021-01-22 02:44

    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()
    

提交回复
热议问题