This is a migrated thread and some comments may be shown as answers.
fetchStrategy.LoadWith with condition
1 Answer 5 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Top achievements
Rank 1
Lexe asked on 08 May 2015, 06:06 PM

Hello !


I have this : 

"var data = this.dataContext.GetAll<Hardwarevendor>().ToList();

this.fetchStrategy.MaxFetchDepth = 5;
this.fetchStrategy.LoadWith<Hardwarevendor>(hv => hv.Platforms);
this.fetchStrategy.LoadWith<Platform>(p => p.Monitors);
this.fetchStrategy.LoadWith<Monitor>(m => {m.Ff_Monitor_Os);
this.fetchStrategy.LoadWith<Ff_Monitor_Os>(ffmo => ffmo.Monitor);
this.fetchStrategy.LoadWith<Ff_Monitor_Os>(ffmo => ffmo.Os);"

 => I want to get all hardwareVendor and for each : I want all platform AND all monitor for all platform.

 The problem is : I want all hardwareVendor and for each : all platform BUT for all platform I want  ONLY monitor non deleted. I ish there is a way to add a condition on the LoadWith ?


Thank you for your help !


1 Answer, 1 is accepted

Sort by
Yavor Slavchev
Telerik team
answered on 12 May 2015, 02:47 PM
Thank you for your interest in Telerik products.

I'm afraid this scenario is not supported. When you use LoadWith() of the fetch strategy, you are actually indicating which member should be loaded together with the entity from the generic parameter. It does not indicate the actual data that is loaded. A predicate in this case is not supported.
However, you can workaround this limitation by creating a SQL Server view that loads filtered data and map an entity to this view. Then you can use the fetch strategy in the same manner as when you are using table. Have in mind that Telerik DataAccess ORM requires entiites to have primary key but you cannot define primary key for views. Have a look at this article for information how to solve this issue.

I hope this information is helpful.

Yavor Slavchev
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
LINQ (LINQ specific questions)
Asked by
Top achievements
Rank 1
Answers by
Yavor Slavchev
Telerik team
Share this question