linq-to-sql group by with count and custom object model

前端 未结 2 1400
故里飘歌
故里飘歌 2021-01-23 10:53

I\'m looking to fill an object model with the count of a linq-to-sql query that groups by its key.

The object model looks somewhat like this:

public clas         


        
2条回答
  •  无人共我
    2021-01-23 11:17

    Your range variable is not correct in the subqueries:

         CountSomeByte6 = TheCount.Where(TheCount => TheCount.Key == 6)
                                            .Select(TheCount).Count(), 
    

    In method notation you don't need the extra select:

    CountSomeByte6 = TheCount.Where(theCount => theCount.Key == 6).Count(), 
    

    If you want to use it anyway:

    CountSomeByte6 = TheCount.Where(theCount => theCount.Key == 6).Select(theCount => theCount).Count(), 
    

提交回复
热议问题