开发者

Difference between ".OrderBy(p => p.Id)" and "orderby p.Id ascending" [duplicate]

开发者 https://www.devze.com 2023-03-08 03:39 出处:网络
This question开发者_如何学Python already has answers here: Closed 11 years ago. Possible Duplicates:
This question开发者_如何学Python already has answers here: Closed 11 years ago.

Possible Duplicates:

Which LINQ syntax do you prefer? Fluent or Query Expression

LINQ: Dot Notation vs Query Expression

What is the difference between the two methods of sorting in Linq? Is one better than the other performance wise?


The query syntax is syntactical sugar that gets converted to the method approach. There's no difference, use whatever style suits your needs.

From the LINQ Query Syntax versus Method Syntax MSDN article:

there is no semantic difference between method syntax and query syntax. In addition, some queries, such as those that retrieve the number of elements that match a specified condition, or that retrieve the element that has the maximum value in a source sequence, can only be expressed as method calls.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号