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 have a base class: class Test int Id DateTime TestDate int Person int TestType string Result etc
and a number of descendants; AudioTest, VisionTest, LungTest etc. I am looking at class table inheritance. If I do: var items = from e in UnitOfWorkScope.Current.Query<Test>() where whatever select e;
Thanks
Sean
|
|
|
1. Yes. 2. Yes. 3. Make the fields in the descendant classes part of a named aggregate. This will cause them to be lazy loaded. (Note that the entities will still be of the derived type -- this just defers materialising the fields that are specific to the derived type.) Or do a projection instead of materialising entities. |
|
|
By projection, do you mean: var items = from e in UnitOfWorkScope.Current.Query<Test>() where whatever select new (e.Id, e.Result, e.TestDate, e.Person, e.TestType);
Sean |
|
|
Yes, that's right. You can also project into a named type rather than an anonymous type, if you need something a bit more structured. (However, even if you use a named type it will still not be a LightSpeed entity.) |
|
|
Nope, the projection is still hitting the child tables. Running the query: public void Test() public IQueryable<TEntity> GetAll<TEntity>() where TEntity : Entity
returns SELECT (snip all the HealthTestsAudio fields) |
|
|
Hi Sean, As you would notice the SQL statement does not actually contain the projection, but this is because you have the "GetAll" function which has a select operation on it which means our parser will not consider this a candidate for server side projection. Try changing your GetAll<> function to just: return UnitOfWorkScope.Current.Query<TEntity>(); as that is already of the type IQueryable<TEntity>. That should change the query back into one where you have the server side projection and no need for joining the child tables.
Jeremy |
|
|
Ah, that did it. Thanks. |
|