0
from teamBudget in TeamBudgets
where teamBudget.TeamID == 71002
join teamBroker in TeamBrokers on 71002 equals teamBroker.TeamID
join goal in Goals on teamBroker.GlobalBrokerID equals goal.GlobalBrokerID
group goal by goal.GlobalBrokerID into g

select new 
{
    // TeamID=teamBroker.TeamID,
    // MTDGoal=teamBudget.Sum(t => t.Budget),
    RevenueMTDCurrent = g.Sum(x => x.RevenueMTDCurrent)
}

评论部分有问题。如何访问未包含在分组元素中的任何数据?

4

1 回答 1

2

您需要对多个字段进行分组,然后只有您可以访问该数据。

var result = from i in
                     (from uh in db.UserHistories
                      where uh.User.UserID == UserID && uh.CRMEntityID == (int)entity
                      select new { uh.ActionID, uh.ActionType, uh.ObjectID })
                 group i by new { i.ActionID, i.ActionType, i.ObjectID } into g
                 select new { g.ActionID, g.ActionType, g.ObjectID };

希望这会有所帮助

于 2011-02-18T09:51:36.447 回答