2017-06-01 7 views
0

こんにちは私はtable2からstudentIdとScoreを選択するために以下のクエリを使用しています。 このクエリでユーザーを選択することができます
from v in dc.tbl_Students select vしかし、私は自分のIDを持っているいくつかのユーザーを選択します。linqのSQLからいくつかのidsを選択

var qBestMan = (from T in (((from tbl_ActPoints in dc.tbl_ActPoints 
             select new 
             { 
              StudentId = (int?)tbl_ActPoints.StudentId, 
              Score = (int?)tbl_ActPoints.Score 
             }).Concat(
       from tbl_EvaPoints in dc.tbl_EvaPoints 
       select new 
       { 
        StudentId = (int?)tbl_EvaPoints.StudentId, 
        Score = (int?)tbl_EvaPoints.Score 
       }))) 
         group T by new 
         { 
          T.StudentId 
         } into g 
         orderby g.Sum(p => p.Score) descending 
         select new 
         { 
          g.Key.StudentId, 
          HighScoreUser = g.Sum(p => p.Score) 
         }).ToArray(); 

答えて

0

このような何か試してみてください:

 //qBestMan must be a List, or a IEnumarable and not a Array. Remove the .ToArray() at the end, or substitute it by .ToList() 
     var Result = from users in dc.tbl_Students 
         join bestMen in qBestMan on bestMen.StudentId equals users.userid        
         select new 
         { 
          //fields that you want 
          example = users.example, 
          other = bestMen.other 
         }; 
関連する問題