asp.net - Invalid anonymous type member declarator in LINQ -


i have 2 entities. 1 "students" while "subjects".

the details of 2 entities like:

students { id, name}  subjects { studentid, subjectname, passed} 

where "passed" of boolean type.

now want query student name , count of subject can pass follows:

var result = s in db.students  select new {s.name, s.subjects.count(i => i.passed.equals(true)}; 

but error msg:invalid anonymous type member declarator. anonymous type members must declared member assignment, simple name or member access.

i dun know how solve it. me please?

this means need name anonymous type's properties cannot inferred

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

usually, property name enough, using count method, property has no inherent name


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -