Junior Mayhe
Junior Mayhe

Reputation: 16411

What is more performant in Linq multiple order by?

which of the sorted lists below is more performant:

var sortedList = data.OrderBy(row => row.Fullname).ThenBy(row => row.Age);

or this one:

var sortedList = from row in data 
                 orderby row.Fullname, row.Age
                 select row;

Upvotes: 4

Views: 172

Answers (3)

sra
sra

Reputation: 23973

That is both the same. There will be no difference.its more about how you like typing

Upvotes: 2

abatishchev
abatishchev

Reputation: 100258

Query syntax is being converted to Method syntax by compiler, so they are the same.

Upvotes: 7

zerkms
zerkms

Reputation: 254916

They both will be converted to the same expression.

Upvotes: 6

Related Questions