Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Feature: Query: We should not require OrderBy before Skip [1449]

$
0
0
Currently in Linq to Entities we require OrderBy clause before Skip. We could try lifting that requirement, to resemble Linq to Objects more. Moreover we don't require Ordeby when doing other paging operations (Take, FirstOrDefault). Also we don't complain if result of the Orderby yields non-deterministic results (i.e. order by constant or by value that happens to be repeating itself)
Comments: I'm currently quite angry at EF because of this. I believe you made this because of how SQL Server required some order column in the OVER clause to do paging, but I'm using MySQL that has the "LIMIT start, count" and there is no need for this kind of check. As a workaround, I'm doing this: ```cs query.OrderBy(i => (string) null).Skip(x).Take(y); ``` This creates the query like: ```sql SELECT `Project`.`OtherField`, FROM ( SELECT NULL AS `C1`, `OtherField` FROM `newsletter_lista` AS `Extent1` ) AS `Project` ORDER BY `Project`.`C1` ASC LIMIT 0,10 ``` I'm just hoping MySQL query planner can optimize this and skip the order by entirely.

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>