I am trying to run the following linq query:
var entries = from entry in _db.Entries select new CommentSummary() { NumberOfComments = entry.Message.Count(), UserName = entry.Name };
when I execute the request, it throws the indicated error: Message = DbExpressionBinding requires an input expression with the ResultType set. Parameter Name: Input
If i use
var entries = from entry in _db.Entries group entry by entry.Name into groupedByName orderby groupedByName.Count() descending select new CommentSummary { NumberOfComments = groupedByName.Count(), UserName = groupedByName.Key };
there is no error, but comments are not taken into account correctly: all NumberOfComments values ββare "1", and must also be "1" and "0". Any ideas? Thanks
source share