Invalid anonymous type member declarator in LINQ

前端 未结 2 654
旧巷少年郎
旧巷少年郎 2021-02-19 22:45

I have two entities. One is \"Students\" while another is \"Subjects\".

The details of the two entities is something like:

students { id, name}

subject         


        
2条回答
  •  感情败类
    2021-02-19 23:21

    This means that you need to name your anonymous type's properties that cannot be inferred

    select new 
    {
        s.name, 
        Count=s.subjects.Count(i => i.passed.Equals(true))
    };
    

    Usually, the property name is good enough, however you are using the Count method, so that property has no inherent name

提交回复
热议问题