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 want to fetch columns from 4 tables which i have already joined in Query class object and also specified the QueryExpression, the code is fine when i am using : UnitofWork.Find but i am not able to fetch columns from all four tables How can i use the Find method or any method of unitofWork base and get columns of multiple tables? Supporting code: Query query = new Query(combinedQueries)
{
Join = (Join.Inner In similar way i want to fetch something like: using (var unitOfWork = LsContext.CreateUnitOfWork())
{
dbAds = unitOfWork.Find |
|
|
The problem with the code you have listed is that you are mixing UnitOfWork.Find and then LINQ queries with the intention of referencing the other entities in the query. UnitOfWork.Find returns a list of entities which are of the EntityType on the query based on the specification of the query you are executing. So you will only ever have the primary entity available and not the joined entities in the LINQ part of your query because it is now running client side against the returned set of objects from the .Find call. Since you are using LINQ you should look at using a strongly typed UnitOfWork which has the pre-generated IQueryable properties on it - we automatically code generate this if you have System.Core referenced in the assembly containing your model. Have a read through http://www.mindscapehq.com/documentation/lightspeed/Basic-Operations/Querying-the-Database-Using-LINQ for some more detail about this. If you are executing the queries against an IQueryable you will have access to the joined entities when you perform a .Select since they will still be in scope.
|
|