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
|
I am having a problem with Take in LS 3 (20/1/2010) against ms sql 2008. I have the following code to search for Doctors based on their name: public IQueryable<Doctor> SearchDoctors(string search)
Without the Take(), I get 494 records searching for "a". With the Take(), I only get 21 records. Rather than returing the first 50 matches, Lightspeed is returning all the matches in the first 50 records in my dataset. This is not at all what I want or expected. The generated sql is: Without Take(): {SELECT
{SELECT
Any ideas? |
|
|
Anyone? |
|
|
Hi Sean, Sorry for the delay in follow up on this. I will have a look at this now and get back to you once we have made some further progress here.
Jeremy |
|
|
Hi Sean, This is a bit of a nuance in the behavior of Count() vs Find(). If you are performing a distinct count then the count will push any criteria to the inner query which makes it consistent with Find() (and the behavior you are expecting). If you dont make it distinct then the criteria will remain on the outer query which allows the count to be performed over the paged result set meaning you get a different result. This allows things like Contains() to be supported in paged scenarios. So for the above, you could either do a .ToList().Count or .Distinct().Count() to match your intent. Appreciate this is slightly non-intuative, so we will see if this can be improved and I will pop a ticket on the backlog to review this. Any change in the interim would be breaking so we wouldnt be implementing this until the next milestone release if we go ahead with anything.
Jeremy |
|