2014-11-04 56 views
0
select COUNT([User].UserId) 
    from [User] join Team on [User].TeamId = Team.TeamId where Team.TeamId =2 

這裏是我到目前爲止,但我無法弄清楚如何實現需要轉換成SQL連接與數查詢到LINQ,並通過它來查看

var countUser = from u in db.Users 
          join t in db.Teams 
          on u.TeamId equals t.TeamId 
          where (u.TeamId == 11) 
          select new 
          { 
          }; 
+0

這裏是一個非常好的開始學習Linq的好地方,它有很多例子[C#Linq Examples](http://www.dotnetperls.com/linq) – MethodMan 2014-11-04 17:51:04

回答

0

試試這個

var countUser = (from u in db.Users 
          join t in db.Teams 
          on u.TeamId equals t.TeamId 
          where (u.TeamId == 11) 
          select new 
          { 
           u.UserId 
          }).Count(); 
+0

我已經在我的索引操作方法上做了這個,必須通過這個結果來查看和索引方法已經ret我想看一些東西。請幫忙 – Felixerity 2014-11-05 10:08:57