fetchStrategy.LoadWith with condition

Thread is closed for posting
2 posts, 0 answers
  1. Lexe
    Lexe avatar
    1 posts
    Member since:
    May 2015

    Posted 08 May 2015 Link to this post

    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 !


  2. Yavor Slavchev
    Yavor Slavchev avatar
    22 posts

    Posted 12 May 2015 Link to this post

    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.
Back to Top