Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is IOrderedQueryable.AsEnumerable() still ordered?

context.EntitySet.AsEnumerable().OrderBy() returns an IOrderedEnumerable which is guaranteed to be ordered but it looks like the sorting is done client side.

context.EntitySet.OrderBy().AsEnumerable() preserves the expression as an IOrderedQueryable until it finally becomes an IEnumerable. I believe the ordering is done by the database in this case which is preferable. In some basic tests the output appears to still be ordered. Is ordering guaranteed even though IOrderedQueryable.AsEnumerable() only returns an IEnumerable?

like image 805
Monstieur Avatar asked Oct 24 '25 01:10

Monstieur


1 Answers

Yes, it is guaranteed. AsEnumerable is only a simple forward-only wrapper (and IOrderedEnumerable is only a marker interface in fact).

like image 68
Serg Rogovtsev Avatar answered Oct 25 '25 17:10

Serg Rogovtsev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!