LoadWith<T> - Eager Loading

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
kboeckm
Posts: 10
Joined: Tue 14 Jun 2011 20:47

LoadWith<T> - Eager Loading

Post by kboeckm » Wed 22 Jun 2011 19:25

I'm using the LoadWith DataLoadOption to eager load several child entities of my parent object. I have a parent object named Bank. It contains zero to many relationships for Category, BankText, and BankLimit. I would expect the eager loading feature to return a single Bank with it's child entities (collections) populated. Instead, I'm receiving a numerours rows per bank. Isn't the intent of the ORM to roll those rows up into the parent object? How can I make that happen?

Visual Studio 2010
dotConnect for Oracle v6.30.172
LinqConnect v 2.50.25
Given the code below:

Code: Select all

DataLoadOptions dataLoadOptions = new DataLoadOptions();
dataLoadOptions.LoadWith(b => b.Categories, FetchMode.Join);
dataLoadOptions.LoadWith(b => b.BankTexts, FetchMode.Join);
dataLoadOptions.LoadWith(b => b.BankLimits, FetchMode.Join);
db.LoadOptions = dataLoadOptions;
db.DeferredLoadingEnabled = false;

return (from b in db.Banks where b.Bankkey == bankKey select b).FirstOrDefault();
The query generated looks like:
SELECT t1.NAME, t1.AWARDTYPE, t1.BANKKEY, t1.COMPANYKEY, t1.PERIODKEY, t1.FAMILYTYPE, t1.ISDISPLAYED, t1.ISNOVALUE, t1.CHECKDATE, t1.LOCKEDBY, t1.CREATEDBY, t1.CREATEDDATE, t1.UPDATEDBY, t1.UPDATEDDATE, t1.COMPLETEDATETYPE, t4.BANKKEY AS BANKKEY1, t4.DEFAULTTEXTKEY, t4.CONTENT, t4.CREATEDBY AS CREATEDBY1, t4.CREATEDDATE AS CREATEDDATE1, t4.UPDATEDBY AS UPDATEDBY1, t4.UPDATEDDATE AS UPDATEDDATE1, t3.CATEGORYKEY, t3.BANKKEY AS BANKKEY2, t3.MINAWARD, t3.MAXAWARD, t3.ISREQUIRED, t3.ISNOVALUE AS ISNOVALUE1, t3.SEQUENCE, t3.CREATEDBY AS CREATEDBY2, t3.CREATEDDATE AS CREATEDDATE2, t3.UPDATEDBY AS UPDATEDBY2, t3.UPDATEDDATE AS UPDATEDDATE2, t3.ISACTIVE, t5.BANKKEY AS BANKKEY3, t5.FAMILYSTATUS, t5.MINAWARD AS MINAWARD1, t5.MAXAWARD AS MAXAWARD1, t5.ISMINSHOWN, t5.ISTRACKERSHOWN, t5.CREATEDBY AS CREATEDBY3, t5.CREATEDDATE AS CREATEDDATE3, t5.UPDATEDBY AS UPDATEDBY3, t5.UPDATEDDATE AS UPDATEDDATE3
FROM (
SELECT t2.NAME, t2.AWARDTYPE, t2.BANKKEY, t2.COMPANYKEY, t2.PERIODKEY, t2.FAMILYTYPE, t2.ISDISPLAYED, t2.ISNOVALUE, t2.CHECKDATE, t2.LOCKEDBY, t2.CREATEDBY, t2.CREATEDDATE, t2.UPDATEDBY, t2.UPDATEDDATE, t2.COMPLETEDATETYPE
FROM INCENTIVE.BANK t2
WHERE t2.BANKKEY = 143
) t1
LEFT OUTER JOIN INCENTIVE.CATEGORY t3 ON t1.BANKKEY = t3.BANKKEY
LEFT OUTER JOIN INCENTIVE.BANKTEXT t4 ON t1.BANKKEY = t4.BANKKEY
LEFT OUTER JOIN INCENTIVE.BANKLIMIT t5 ON t1.BANKKEY = t5.BANKKEY
ORDER BY t1.BANKKEY, t1.BANKKEY, t1.BANKKEY

Error Message:
"Sequence contains more then one element"

The stack trace reads like this:
Devart.Data.Linq.Provider.DataProvider.ReadQuery(CompiledQuery compiledQuery, IDbConnection con, k dataReader)\r\n at Devart.Data.Linq.Provider.DataProvider.ExecuteQuery(CompiledQuery compiledQuery, Object[] parentArgs, Object[] userArgs, Object lastResult)\r\n at Devart.Data.Linq.Provider.DataProvider.ExecuteAllQueries(CompiledQuery compiledQuery, Object[] userArguments)\r\n at Devart.Data.Linq.Provider.DataProvider.Devart.Data.Linq.Provider.IProvider.Execute(Expression query)\r\n at Devart.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)\r\n at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)\r\n at Staywell.Incentives.Repository.BankRepository.c__DisplayClass1.b__0() in C:\src10\Staywell\Main\Staywell.Incentives\Repository\Repository\BankRepository.cs:line 56\r\n at Staywell.Incentives.Repository.ExceptionManager.Call[T](Func`1 function, IExceptionStrategy strategy) in C:\src10\Staywell\Main\Staywell.Incentives\Repository\Repository\Exceptions\ExceptionManager.cs:line 53"

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 23 Jun 2011 16:08

Thank you for the report, we have reproduced this problem. We will inform you when it is fixed.

kboeckm
Posts: 10
Joined: Tue 14 Jun 2011 20:47

Post by kboeckm » Wed 03 Aug 2011 16:10

When will this be fixed? It's been six weeks and this sure seems to be an important defect.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 04 Aug 2011 15:53

We are working on this problem, but cannot provide any timeframe at the moment. We will post here as soon as it is fixed.

emp51302
Posts: 46
Joined: Fri 19 Aug 2011 20:57

Post by emp51302 » Thu 25 Aug 2011 13:53

Has this issue been fixed? Curious to know, since I may be doing a query like that soon. Thanks

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 26 Aug 2011 12:57

We have fixed this issue. We will post here when the corresponding build is published.

Also, the fix should be available in LinqConnect 3.0 Beta:
http://www.devart.com/linqconnect/download.html
For the detailed information about the new functionality of the Beta version, please refer to
http://www.devart.com/forums/viewtopic.php?t=21842

luc.dobler
Posts: 6
Joined: Thu 24 Mar 2011 08:41

Post by luc.dobler » Mon 29 Aug 2011 07:40

Hi,

I am experiencing the same issue. When looking at the SQL trace, all the expected data are loaded but the entities are not constructed.

I downloaded version 3 BETA and got the message that this does not work in Direct Mode.

Exact message is :
Express Edition doesn't support Direct mode. Do not use Direct parameter of connection string. Refer to dotConnect for Oracle editions matrix
I tried to fix it with the licensing tool, without success. Any hint ? Version 3 is useless to us if we cannot use Direct Mode.

Thanks in advance for any advice.
Luc

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 29 Aug 2011 13:16

LinqConnect (as a product) includes the Express versions of data providers, thus it does not support the Direct connection mode.

To use the Direct mode when trying LinqConnect 3.0 Beta, you can try performing the following:
- perform the minimal installation of the latest build of dotConnect for Oracle Professional;
- save the Devart.Data and Devart.Data.Oracle assemblies from this build;
- install LinqConnect Beta;
- set references to the Devart.Data.Linq and Devart.Data.Oracle.Linq assemblies from the Beta version in your application;
- set references to Devart.Data and Devart.Data.Oracle from dotConnect for Oracle Professional.
Please tell us if this helps.

Otherwise, you can wait for the nearest build, in which this fix will be available for both LinqConnect and dotConnect for Oracle. We plan to publish the new build in about a week.

luc.dobler
Posts: 6
Joined: Thu 24 Mar 2011 08:41

Post by luc.dobler » Wed 31 Aug 2011 05:13

Hi Stanislav,

Thanks for the hint but I uninstalled the beta and will wait for the next build.
Regards,
Luc

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 07 Oct 2011 09:47

The fix for this issue is available in the latest 3.0.5 build of LinqConnect. The new build can be downloaded from
http://www.devart.com/linqconnect/download.html
(the trial only) or from Registered Users' Area (for users with active subscription only).

For more information about the fixes and improvements available in LinqConnect 3.0.5, please refer to
http://www.devart.com/forums/viewtopic.php?t=22168

Post Reply