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
|
var posts = unitofwork.Posts.ToList() var blaposts = posts.Where(p => p.bla=bla).ToList() var userposts = posts.Where(p => p.user=theseguys).ToList() ============================================================= OR does Lightspeed know enough to optimize database access with just code like this: var blaposts = unitofwork.Posts.Where(p => p.bla=bla).ToList() var userposts = unitofwork.Posts.Where(p => p.user=theseguys).ToList()
Thanks. |
|
|
LINQ queries written against UnitOfWork.Posts will be translated to SQL and run efficiently on the database. LINQ queries written against UnitOfWork.Posts.ToList() will result in the entire set of Posts being fetched into a List, which will then be processed using LINQ to Objects. So your second set of queries will be much more efficient. You can verify this by setting UnitOfWork.Context.Logger = new TraceLogger() and examining the SQL in the Visual Studio Output window. See http://www.mindscapehq.com/documentation/lightspeed/Basic-Operations/Querying-the-Database-Using-LINQ for more information. |
|