Using entity framework, "order by Col1, Col2."

.net c# entity-framework linq

Question

I need to use the entity framework to arrange by two columns.

How does it work?

return _repository.GetSomething().OrderBy(x => x.Col1   .. Col2)?

i.e

SELECT * FROM Foo ORDER BY Col1, Col2
1
112
4/21/2019 1:43:57 PM

Accepted Answer

Try OrderBy(x => x.Col1).ThenBy(x => x.Col2) . In any case, it is a LINQ feature and not only an EF feature.

235
11/9/2009 12:09:07 PM

Popular Answer

Another approach is:

qqq.OrderBy(x => new { x.Col1, x.Col2} )


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow