This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi,
Lightspeed tags on an order by clause on a standard query. Is there any way to tell lightspeed to not use an "order by" clause as on occassions the ordering of records is not required and will slow retrieval down
Thanks |
|
|
I believe we only automatically emit an "order by" clause when loading an association, and in that case it defaults to order by ID which should be fast because ID will be the primary key. Is this the scenario you're referring to, or have you seen it in other cases? If the latter, can you check you haven't inadvertently set the Order By option on the entity class? |
|
|
Order by is not set at the entity level Not sure what you mean by "loading an association" - sorry :-( I run this code:
string desc = ""; LightSpeedContext.Logger = new TraceLogger() using (var uow = LightSpeedContext.CreateUnitOfWork()) {
desc = titles.Description; }
Logger output shows: SELECT
I don't understand why an "order by" clause is generated.
Thanks |
|
|
The OrderBy clause is being added because you are using paging (which is because you are using Single). If no ordering is explicitely specified we will order by Id when paging is applied.
Jeremy |
|