0

これまでで最も複雑な linq クエリを作成しましたが、必要なものがまだありません。このクエリから、EventStudents テーブル内でDateDeleted == null. したがって、StudentCount = ev.EventStudents - ここで、DateDeleted == null .Count() です。誰でもこれを手伝ってもらえますか?

var inf = (from ev in db.Events
       where (ev.StartDate >= beginDate && ev.StartDate <= endDate)
        && ev.DeletedDate == null
       orderby ev.StartDate descending
       select new
      {
          EventID = ev.EventID,
          EventTitle = ev.Title,
          EventDate = ev.StartDate,
          StudentCount = ev.EventStudents.Count(),
          CreatedUsername = ev.CreatedUsername
      }).AsEnumerable().Select(x => new
      {
          EventID = x.EventID,
          EventTitle = x.EventTitle,
          EventDate = x.EventDate,
          StudentCount = x.StudentCount,
          CreatedUsername = x.CreatedUsername,
          CreatedFullname = sortedUserDictionary.Where(u => u.Value == x.CreatedUsername)
          .Select(f => f.Key)
          .FirstOrDefault() ?? x.CreatedUsername
      });
4

1 に答える 1