1

I have the following SQL query:

SELECT Comment, JD, Jurisdiction, RegStatus, Region, SPDR_NAME 
FROM dbo.Registered_status_by_year 
GROUP BY Comment, JD, SPDR_NAME, Region, Jurisdiction, RegStatus 
HAVING (Region = @Region) ORDER BY JD

I am trying to convert it to linq to entities. I have the following, so far:

var result = (from x in myEntities.IRTStatusByYearSet
                          group x by new { x.Comment, x.JD, x.SPDR_NAME, x.Region, x.Jurisdiction, x.RegStatus } into g
                          select g);

The problem is that I can't seem to use the "orderby" because "g" doesn't have any "properties" that are the column names.

Does anyone know how I might do this? I have looked for examples of doing the order by with grouping, but all of them show only grouping by one thing, or ordering by the "count" of items in grouping, instead of by some other value.

1 Answer 1

2

Have you tried orderby g.Key.JD?

var result = (from x in myEntities.IRTStatusByYearSet
              group x by new { x.Comment, x.JD, x.SPDR_NAME, x.Region, x.Jurisdiction, x.RegStatus } into g
              orderby g.Key.JD
              select g);
Sign up to request clarification or add additional context in comments.

1 Comment

That is TOTALLY it.. thank you so much! I will mark this as answered as soon as the 10 mins is up. =)

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.