Need help with converting a SQL query to LINQ query

RadhaKrishnaKiJaya
RadhaKrishnaKiJaya used Ask the Experts™
on
Hi Experts,
I want to convert this simple query to a LINQ query in C#.
select distinct c.MemberID,max(c.approved)  from Claims c
join member m on c.MemberID = m.MemberId
where m.Id = 910318 and  c.PointsEarned > 0 group by c.MemberID

Open in new window

Any help is appriciated!
Thanks in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Architect - Coder - Mentor
Commented:
Hi,

What about:
var result = (from c in Claims
join m in Member on c.MemberID equals m.MemberId
where m.Id = 910318 && c.PointsEarned > 0)
.Select(g => new { MemberID = g.MemberID, Approved = g.Max(x => x.approved) })
.Distinct(x=>x.MemberID)
.GroupBy(x=>x.MemberID);

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial