Queries from DataLoadOptions not optimized

Queries from DataLoadOptions not optimized

Postby Settler » Sat 10 Apr 2010 08:46

I have 3 tables.
Table1 reference to Table2.
Table2 reference to Table3.

I want to load Table2 with loaded references to Table3.

My linq:
Code: Select all
            using (var context2 = new MyDataContext())
            {
                var options = new DataLoadOptions();
                options.LoadWith(o => o.Table3);
                context2.LoadOptions = options;
                context2.DeferredLoadingEnabled = false;
                var values = from tab1 in context2.Tables1
                             where tab1.IdParent == 1
                             select tab1.Table2;
            }

When this linq is executed in SQL query I see only one inner join between Table1 and Table2. And many queries to Table3.

If I rewrite code to this:
Code: Select all
            using (var context2 = new MyDataContext())
            {
                var options = new DataLoadOptions();
                options.LoadWith(o => o.Table3);
                context2.LoadOptions = options;
                context2.DeferredLoadingEnabled = false;
                var values = from tab1 in context2.Tables1
                             where tab1.IdParent == 1
                             select new
                                       {
                                              IdTable2 = tab1.Table2.Id,
                                              IdTable3 = tab1.Table2.Table3.Id,
                                              Table3Name = tab1.Table2.Table3.Name
                                       };
            }

The result will be as I want, but here I not have classes. What do I wrong with DataLoadOptions?

And more. Why LoadWith() attached method always throw NotSupportedException with dotConnect for PostgreSQL? For example in this linq:
Code: Select all
            using (var context2 = new MyDataContext())
            {
                var values = (from tab1 in context2.Tables1
                             where tab1.IdParent == 1
                             select tab1.Table2).LoadWith(o=>o.Table3);
            }


dotConnect for PostgreSQL 4.65.79.0
Settler
 
Posts: 19
Joined: Mon 01 Mar 2010 16:32

Postby AndreyR » Mon 12 Apr 2010 16:48

You can find some explanations on the joining only one association level in my comment to this post:
http://www.devart.com/forums/viewtopic.php?p=54393
As for the PostgreSQL NotSupportedException issue, I have reproduced the issue, it is under investigation now.
I will post here about the results of our investigation.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby AndreyR » Wed 21 Apr 2010 15:53

The scenario concerning LoadWith is not supported yet.
The problem is associated with the fact that LoadWith is applied not to DataContext.Table instance.
We plan to add support for such scenarios in one of the future builds, but no timeframe is available.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby Settler » Thu 22 Apr 2010 12:01

Ok, thnx. Let me know if you add support for LoadWith.
Settler
 
Posts: 19
Joined: Mon 01 Mar 2010 16:32

Postby Settler » Fri 23 Apr 2010 06:49

Hm... I try to use LoadWith method applied to Table like this:
Code: Select all
using (var context2 = new MyDataContext())
{
   var values = from tab2 in context2.Tables2.LoadWith(o=>o.Table3) select tab2;
}

Not catch exception, but in SQL query I not see inner join. Table3 still load in another queries. I'm do something wrong here?
Settler
 
Posts: 19
Joined: Mon 01 Mar 2010 16:32

Postby AndreyR » Mon 26 Apr 2010 16:49

I have made a simple test using the latest 4.90.124 build of dotConnect for PostgreSQL and succeeded.
Could you please send me a small test project illustrating the issue?
Please add the script of DB objects you are using.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to dotConnect for PostgreSQL