开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜