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
|
What's the difference between: FirstOrDefault(b => b.Id == Id) and findById ? Is there somewhere I can read up on the return values of these things like a javadoc? |
|
|
In terms of their results? Nothing. Both will return the entity with the specified ID if it exists, or null if it does not. However, FindById is typically more efficient. Because LightSpeed knows that FindById is a plain ID lookup, it checks to see whether the entity is already loaded, and skips the database query if it is. Even if the entity is not already loaded, FindById has a fixed query plan, so LightSpeed saves a compiled version of the query to make it run faster on the second and subsequent usages. By contrast, LightSpeed sees FirstOrDefault(b.Id == id) as an arbitrary query which it must submit to the database. It doesn't analyse the query and realise it could be replaced by FindById, and it doesn't compile the query unless you ask it to. The API documentation is at http://www.mindscapehq.com/Help/LightSpeed/Index.aspx (there is also a local copy installed with LightSpeed which may be more convenient). This doesn't cover LINQ methods because those are defined by the .NET Framework (see http://msdn.microsoft.com/en-us/library/system.linq.queryable.aspx). |
|