Fetch Plan

4 posts, 0 answers
  1. john
    john avatar
    67 posts
    Member since:
    Jan 2012

    Posted 28 Nov 2012 Link to this post

    If I have two table T_BS_FUNCTION with 1 parent record and T_BS_RULE.with 2 child record. Could help to indicate the calling time for DB for following two cases:
    A:

    using (EntitiesModel dbContext = new EntitiesModel())
                {
                    IQueryable<T_BS_FUNCTION> query = from c in dbContext.T_BS_FUNCTIONs
                                                      select c;

                    foreach (T_BS_FUNCTION customer in query)
                    {
                        Console.WriteLine(customer.DATE_CREATED);
                        foreach (T_BS_RULE order in customer.T_BS_RULEs)
                        {
                            Console.WriteLine("\t{0}", order.AUTHOR);
                        }
                    }
                }

    B:

     using (EntitiesModel dbContext = new EntitiesModel())
                {
                    Telerik.OpenAccess.FetchOptimization.FetchStrategy fetchStrategy = new Telerik.OpenAccess.FetchOptimization.FetchStrategy();
                    fetchStrategy.LoadWith<T_BS_FUNCTION>(c => c.T_BS_RULEs);
                    dbContext.FetchStrategy = fetchStrategy;

                    IQueryable<T_BS_FUNCTION> query = from c in dbContext.T_BS_FUNCTIONs
                                                      select c;

                    foreach (T_BS_FUNCTION customer in query)
                    {
                        Console.WriteLine(customer.DATE_CREATED);
                        foreach (T_BS_RULE order in customer.T_BS_RULEs)
                        {
                            Console.WriteLine("\t{0}", order.AUTHOR);
                        }
                    }
                }
  2. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 28 Nov 2012 Link to this post

    Hi john,

    Could you please elaborate on the meaning of calling time - are you looking for performance metrics, or you would like to know the flow of database calls for the code you specified?

    I am looking forward to your feedback.

    Greetings,
    Ivailo
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
  3. DevCraft banner
  4. john
    john avatar
    67 posts
    Member since:
    Jan 2012

    Posted 28 Nov 2012 Link to this post

    The calling is for DB.
  5. Hristo Marinov
    Admin
    Hristo Marinov avatar
    13 posts

    Posted 03 Dec 2012 Link to this post

    Hello John,

    When you query for an object with Telerik OpenAccess ORM you actually retrieve only the object you requested. The related objects are not automatically fetched at the same time. With the FetchStrategy class you can specify which related objects to be load with the requested one from the database.

    In your scenario the difference between the queries is that when you don’t use a fetch strategy, Open Access ORM will execute the query for the customers, but for the orders, the ORM will execute a different query for each needed order. With the fetch strategy you specify that when you want the customers, you also want to load the orders with them.

    For more information about Open Access ORM Fetch Plans API, you can refer to this article.

    To see how much time it takes for your queries to execute, you can use the OpenAccess Profiler and Tuning Advisor. It will help you to view detailed information about all the OpenAccess ORM activities in your application.

    To use our Profiler, first you need to configure the project you want to analyze. The configuration depends on the type of the project and the type of monitoring you want to use.

    1) In case you are using the Visual Designer, with a generated OpenAccessContext:
    - For online monitoring you can see this video or refer to this article  
    - For offline monitoring you can watch this video or read more details here 

    2) If your project is based on a Code Only (Fluent) Model you can follow the instructions in this article 


    More information about the Profiler and Tuning Advisor you can find here.

    Do not hesitate to get back to us if you need additional directions.

    Kind regards,
    Hristo Marinov
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Back to Top