1

I have this situation:

select max(id) from OTX group by AccNo

I want to convert it into a LINQ query but is not working. I tried this but says that 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;
1
  • Is 'XX' the actual name of the member? Commented Jul 11, 2013 at 20:17

2 Answers 2

2

Try

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

or if you want the same as

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

then try

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) } ;
Sign up to request clarification or add additional context in comments.

Comments

0
var result = from otx in datacTx.OTX
             group otxCf by otxCf.AccNo
             into Client
             select new { MaxId = Client.Max(s => s.ID)};

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.