This is a migrated thread and some comments may be shown as answers.

Fetch Plan

3 Answers 72 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
john
Top achievements
Rank 1
john asked on 28 Nov 2012, 08:57 AM
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);
                    }
                }
            }

3 Answers, 1 is accepted

Sort by
0
Ivailo
Telerik team
answered on 28 Nov 2012, 04:49 PM
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.
0
john
Top achievements
Rank 1
answered on 29 Nov 2012, 01:07 AM
The calling is for DB.
0
Hristo Marinov
Telerik team
answered on 03 Dec 2012, 05:44 PM

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.
Tags
General Discussions
Asked by
john
Top achievements
Rank 1
Answers by
Ivailo
Telerik team
john
Top achievements
Rank 1
Hristo Marinov
Telerik team
Share this question
or