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 suspect this was already asked, but I can't find anything. |
|
|
The reason for the query going to the server again, is down to the behavior of the LINQ query. You are probably expecting it to do something similar to uow.FindOne<Item>(3), where it would first lookup the key in the identity map and return the cached entity if it exists. This is finding by key. However, it treats this type of query as a Find<Item> with the criteria of (Id == 3). As with any query which LightSpeed performs, when it fetches a result set and is loading entities (as opposed to a projected result) from the set, it will first load the Id from the current record and then see if it already has that entity in the cache - if it does it returns it, if not it will continue with loading the entity from the record. You will also see the same result if you use FindOne with a query as opposed to a key. Hope that explains it :) If you want to avoid the extra database hit and are searching by key as you are in the example above I would suggest you try using FindOne :) |
|
|
OK, cleared. Thanks Jeremy. |
|