LoadWith not returning entities

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
jasons
Posts: 5
Joined: Wed 21 Oct 2015 01:54

LoadWith not returning entities

Post by jasons » Wed 21 Oct 2015 02:23

I'm not sure if I'm missing something here. We're trialling LinqConnect and are trying a simple operation to return a tree of objects in a single query.
Using the documented method, the following should populate three levels deep:

Code: Select all

            using (var dbc = new DBContext())
            {
                var customers = dbc.CustomerAccounts
                    .LoadWith(ca => ca.QuestionnaireSets
                        .LoadWith(qs => qs.Questionnaires.LoadWith(q => q.QuestionnaireType, FetchMode.Join)
                        , FetchMode.Join), FetchMode.Join)
(*1*)               .Where(ca => !ca.Suspended && ca.QuestionnaireSets.Any(qs => qs.Questionnaires.Any(q => q.QuestionnaireStatusID==3)));

                foreach (var c in customers)
                {
                    Console.WriteLine(c.CustomerAccountName);
                    foreach (var cx in c.QuestionnaireSets) 
                    {
                        Console.WriteLine(" > " + cx.Name);
(*2*)                   foreach (Questionnaire q in cx.Questionnaires)
                        {
                            Console.WriteLine(" > " + q.QuestionnaireID);
                        }
                    }
                }
            }
The where clause works perfectly, and the system performs a valid join in a single query, even correctly filtering on the complex nested where clause (*1*).
But... when the code gets to the nested loop (*2*), the system does a lazy load of all the same entity properties that were returned in the first query!

So, I thought I'd simplify things:

Code: Select all

            using (var dbc = new DBContext())
            {
                var dbo = new DataLoadOptions();
                dbo.LoadWith<CustomerAccount>(ca => ca.QuestionnaireSets, FetchMode.Join);
(*3*)           dbo.LoadWith<QuestionnaireSet>(qs => qs.Questionnaires, FetchMode.SelectByOne);

                dbc.LoadOptions = dbo;

                var customers = dbc.CustomerAccounts;

                foreach (var c in customers.ToList())
                {
                    Console.WriteLine(c.CustomerAccountName);
                }
            }
This does a lazy load of every customer object, yet commenting out the QuestionnaireSet line (*3*) avoids the unnecessary lazy loading.

Oh, and adding the where clause from the first code breaks the call as the generated SQL contains a series of 'ORDER BY' clauses that are invalid within the nested selects.

Am I missing something here? Are these bugs, or am I somehow not using the system in the way you expect?

Cheers,
Jason

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: LoadWith not returning entities

Post by MariiaI » Wed 21 Oct 2015 10:44

Could you please provide us with the additional information:
- the exact version of LinqConnect;
- the DBMS you are working with and its version;
- the definitions of the DataContext class and entity classes (or send us the *.lqml/*.edps files);
- the DDL/DML scripts for the necessary database objects (that are involved in the LINQ queries);
- the generated SQL query ( http://www.devart.com/linqconnect/docs/?Logging.html ), etc.

Or, if possible, send us a complete test project with the corresponding DDL/DML scripts (or test database) and model, with which this issue is reproducible. This will significantly speed up the process of determining the cause of the error and finding the solution for it.

Looking forward to your reply.

jasons
Posts: 5
Joined: Wed 21 Oct 2015 01:54

Re: LoadWith not returning entities

Post by jasons » Wed 21 Oct 2015 11:16

Hi,
This is a SQL server 14 instance using the latest trial downloaded today.
Rather than me spending half a day providing a sample, why don't you create a sample project that retrieves three levels of nested objects, and you can start by seeing if it's a core bug?
If not, send me the sample project and I'd be happy to run it against one of our company servers.

Alternatively, if you'd like me to spend a few hours creating a test scenario for you, can I claim the cost of that time as credit against the cost of the purchased product? As CTO of a development house my time isn't cheap.

I'm considering moving my company standard from Telerik DataAccess to DevArt, but this issue in the very first experiment is concerning, and I'd like to see this working in one of your example projects before I commit half a day to building a sample for you. Are there any projects demonstrating this feature?

Cheers,
Jason

jasons
Posts: 5
Joined: Wed 21 Oct 2015 01:54

Re: LoadWith not returning entities

Post by jasons » Wed 21 Oct 2015 14:01

Here's a piece I wrote against AdventureWorks2014.

https://dl.dropboxusercontent.com/u/345 ... ation3.zip

Cheers,
Jason

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: LoadWith not returning entities

Post by MariiaI » Thu 22 Oct 2015 11:19

We have reproduced the behaviour you've encountered. We will investigate it more clearly and post here about the results as soon as possible.

jasons
Posts: 5
Joined: Wed 21 Oct 2015 01:54

Re: LoadWith not returning entities

Post by jasons » Sat 24 Oct 2015 12:12

Do we have an update on this?

Cheers,
Jason

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: LoadWith not returning entities

Post by MariiaI » Tue 27 Oct 2015 13:40

We will definitely post here about the results as soon as any are available.

jasons
Posts: 5
Joined: Wed 21 Oct 2015 01:54

Re: LoadWith not returning entities

Post by jasons » Thu 29 Oct 2015 11:12

It's been over eight days since I posted this, and there's no feedback. Is it a bug? Is it expected behavior? Is there an alternative way of doing the same thing?
With Telerik DataAccess we generally got a response within 12-24 hours, often with a workaround. At the very least you have to give something back to prevent customers thinking that their issue has been shelved, and so they don't start looking around for alternatives.

As I mentioned in my first posting, I was testing DevArt as a company replacement, but I've decided we will go with with the latest LLBLGen. A question posted there was answered within 3 hours by the lead developer, and in todays D2D market (dev to dev) you need to be on top of this sort of thing. You don't need to fix the bugs quickly; just make sure the end user feels you're working with them to fix the issue and you have their valuable time at heart.

Please take this as feedback, as it's not a rant. I only spent about 6 hours trialing your product, so it's no great loss for me, but it is disappointing. If you lose opportunities during pre-sales, you will have fewer sales, and even fewer renewals.

Regards,
Jason

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: LoadWith not returning entities

Post by MariiaI » Fri 30 Oct 2015 08:12

We are sorry to find out that you are not satisfied with our product.

We have investigated this issue in more details.
There are known issues related to using multi-level LoadWith, and the behaviour you have encountered is one of such cases.
More deep investigation of this issue and finding solutions for it could take some time due to the some peculiarities and its complexity. We will contact you as soon as the issue is fixed or any suitable workaround is available.

As for the our response policy, please refer to https://www.devart.com/linqconnect/docs/support.html.

Post Reply