Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / OpenAccess ORM > General Discussions > How to use FetchStrategy?

Not answered How to use FetchStrategy?

Feed from this thread
  • Zhaoning avatar

    Posted on Jan 5, 2012 (permalink)

    i want to us FetchStrategy class to load of specified related data, and I have read the manual, but there are still some problems.
    example : 
    Package, PackageItem,Sample,TestRequest
    the relation of Package and PackageItem is one to multi;
    the relation of PackageItem and Sample is one to multi;
    the relation of Sample and TestRequest is one to multi;


    1. when i get Package data,it can load PackageItem data and Sample data(The value of the MaxFetchDepth must be greater than 0 and the default one is 3.).  it's normal,I can understand.

    2. when i get PackageItem data,it can load Sample data and TestRequest data.  it's normal,I can understand.

    3.but if i do step 1 after i have done step2,then all of the Package data, PackageItem data ,Sample data and TestRequest data will be loaded.i don't set any FetchStrategy Class to Context,at this time. Why???

    4.whether step 1 or step 2,it's still load three depth data,no matter whether I set MaxFetchDepth = 1.Why???

    my english is very poor,i hope I have expressed it clearly.
     ,

    Reply

  • Zoran Zoran admin's avatar

    Posted on Jan 9, 2012 (permalink)

    Hi Zhaoning,

     As for question number 3, can you share with us the code that you use to fetch the PackageItem and after that the Package objects(steps 2 and 1). If the context instance is one and the same and you have already loaded PackageItem and Sample, it is expected behavior that Package, PackageItem and Sample are loaded once again if you are trying to load the Package object. The reason for this is that the FetchStrategy is being applied on the top-most object in the graph and in this case that object is Package. That means that whenever you load the Package object you will get the PackageItem and Sample objects loaded with it even if you have loaded those objects in another way before that.

    Sending us a code-sample will really be helpful for us to give you the answers for questions 3 and 4 as there are a lot of ways the Fetch Strategies can be applied and they should be used carefully so no additional and unexpected queries are produced.

    All the best,
    Zoran
    the Telerik team

    SP1 for Q3’11 of Telerik OpenAccess ORM is available for download

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / OpenAccess ORM > General Discussions > How to use FetchStrategy?
Related resources for "How to use FetchStrategy?"

OpenAccess ORM Features  |  Documentation  |  Demos  |  Telerik TV  |  Step-by-step Tutorial   ]