1

我有这种情况:

select max(id) from OTX group by AccNo

我想将其转换为 LINQ 查询但不工作。我试过这个,但说 Message = "The member 'XX' has no supported translation to SQL.":

var result = from otx in datacTx.OTX
             group otxCf by otxCf.AccNo
             into Client
             select Client.Max().ID;
4

2 回答 2

2

尝试

var result = from otx in datacTx.OTX
         group otxCf by otxCf.AccNo
         into Client
         select Client.Max(r=>r.id);

或者如果你想要相同的

select AccNo, max(id) from OTX group by AccNo

然后尝试

var result = from otx in datacTx.OTX
         group otxCf by otxCf.AccNo
         into Client
         select new { AccNo = Client.Key , MaxValue= Client.Max(r=>r.id) } ;
于 2013-07-11T20:18:49.580 回答
0
var result = from otx in datacTx.OTX
             group otxCf by otxCf.AccNo
             into Client
             select new { MaxId = Client.Max(s => s.ID)};
于 2013-07-11T20:19:44.327 回答