LoadOptions cannot be changed

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
itcore@vit.ch
Posts: 43
Joined: Wed 17 Sep 2008 11:31

LoadOptions cannot be changed

Post by itcore@vit.ch » Fri 24 Apr 2009 06:46

Hello

I am deleting some entries from a table:

Code: Select all

Customer.LoginInfos.DeleteAllOnSubmit(Customer.LoginInfos.Where(l => l.LoginTime.AddDays(days) (l => l.LoginInfoHistories);
Customer.LoadOptions = dataLoadOptions;

var recordSet = from l in Customer.LoginInfos				select l;
Customer.LoadOptions is null. When I try to assign my dataLoadOptions, I get the exception "LoadOptions cannot be changed". The stack trace is just:
at Devart.Data.Linq.DataContext.set_LoadOptions(DataLoadOptions value)

If I omit the delete statement, I can assign the load options. It seems that once the Customer datacontext is initialized, I cannot change the load options anymore. this is a pitty because I'd like to initialize the datacontext only once and then use different load options when ever I execute a query.
________
Dodge hemi small block
Last edited by itcore@vit.ch on Thu 17 Feb 2011 05:21, edited 1 time in total.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 24 Apr 2009 12:26

This is a designed behaviour for the DataLoadOptions class, because it is a context-level query tuning.
For query-level tuning you can use the Include(Expression) method like in the following example:

Code: Select all

 
var q1 = from cat in db.Productcategories.Include(c=>c.Products)
            select cat;

itcore@vit.ch
Posts: 43
Joined: Wed 17 Sep 2008 11:31

Post by itcore@vit.ch » Tue 05 May 2009 09:48

thank you. that's very interesting. it seems this is something which the microsoft linq implementation for MS SQL does not have. or is there something similar?
________
Chrysler Sohc V6 Engine Specifications
Last edited by itcore@vit.ch on Thu 17 Feb 2011 05:21, edited 1 time in total.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 05 May 2009 11:01

We have implemented the query-level tuning. Now there is the Table.LoadWith(Expression) method which works like
DataLoadOptions.LoadWith(), but for the separate query.
There is no similar functionality in Microsoft LINQ to SQL.

itcore@vit.ch
Posts: 43
Joined: Wed 17 Sep 2008 11:31

Post by itcore@vit.ch » Tue 05 May 2009 12:38

Wow... that's great! Good job!

So what's the difference between Devart's Table.LoadWith(Expression) and Table.Include(Expression)? Both methods seem to work on table-level.
________
Homemade Vaporizers
Last edited by itcore@vit.ch on Thu 17 Feb 2011 05:21, edited 1 time in total.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 06 May 2009 06:14

We have renamed the Include() method to the LoadWith() method.

itcore@vit.ch
Posts: 43
Joined: Wed 17 Sep 2008 11:31

Post by itcore@vit.ch » Wed 20 May 2009 14:48

Hello

I embedded the new version. But now I get the exception "The query operator 'LoadWith' is not supported" when calling the Single() statement (last line) in the following code block:

Code: Select all

var recordSet = from l in PPCustomer.LoginInfos.LoadWith(l => l.LoginInfoHistories)
where l.CookieGuid == guid.ToString()
select l;

return recordSet.Single();
Before I migrated to the new version, my code looked like this...

Code: Select all

var recordSet = from l in PPCustomer.LoginInfos.Include(l => l.LoginInfoHistories)
where l.CookieGuid == guid.ToString()
select l;

return recordSet.Single();
.. and was perfectly working (the only thing which changed was "Include" to "LoadWith")..


Do I have to change anything or is this a bug with the LoadWith method?
________
CYPRUS COOKING
Last edited by itcore@vit.ch on Thu 17 Feb 2011 05:22, edited 1 time in total.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 21 May 2009 10:53

Thank you for the report, this bug is already fixed in the upcoming build of dotConnect for MySQL.

Shalex
Devart Team
Posts: 8088
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 22 May 2009 16:02

The new build of dotConnect for MySQL 5.20.33 is available for download now.
It can be downloaded from http://www.devart.com/dotconnect/mysql/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=14910 .

itcore@vit.ch
Posts: 43
Joined: Wed 17 Sep 2008 11:31

Post by itcore@vit.ch » Wed 27 May 2009 16:20

Hello

There's something I don't understand exactly with the LoadWith method. With the first LoadWith statement I load the first level children (=MailingRecipients), which works fine. But then I also try to load the children of the MailingRecipients (=MailingDownloads). But this seems not to work. How do I have to apply the LoadWith method to achieve this:

Code: Select all

from m in PPCustomer.Mailings.LoadWith(m => m.MailingRecipients)
join mr in PPCustomer.MailingRecipients.LoadWith(mr => mr.MailingDownloads) on m.MailingId equals mr.MailingId
select m
Thank you & best regards
________
No2 vaporizer reviews
Last edited by itcore@vit.ch on Thu 17 Feb 2011 05:22, edited 1 time in total.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 28 May 2009 10:19

The solution is in the following code:

Code: Select all

from m in PPCustomer.Mailings.LoadWith(m=>m.MailingRecipients.LoadWith(mr=>mr.MailingDownloads)) select m;

itcore@vit.ch
Posts: 43
Joined: Wed 17 Sep 2008 11:31

Post by itcore@vit.ch » Thu 28 May 2009 11:02

This does not work.

m.MailingRecipients does not expose a LoadWith method because it's not a Devart.Data.Linq.Table but a Devart.Data.Linq.EntitySet.

Any other suggestions?
________
ANGELINA JOLIE PIC
Last edited by itcore@vit.ch on Thu 17 Feb 2011 05:22, edited 1 time in total.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 28 May 2009 12:51

Please add the "using Devart.Data.Linq;" line to your code.
The LoadWith() method is implemented for IQueryable instances, not only for tables.
Unfortunately, there is a problem with it in the the current build. It is already fixed, the fix will be available in the next build.
As a workaround, you can use the context-level DataLoadOptions class, it doesn't have the problem.

itcore@vit.ch
Posts: 43
Joined: Wed 17 Sep 2008 11:31

Post by itcore@vit.ch » Thu 28 May 2009 14:55

You say, the current build has a problem with the LoadWith method. I also detected a problem with it. Could you have a look at it and tell me if this is the same problem as you mentioned or if I found another bug?

I have the following linq statment:

Code: Select all

var recordSet = (from m in PPCustomer.Mailings.LoadWith(m => m.MailingRecipients.LoadWith(mr => mr.MailingDownloads.LoadWith(md => md.Mailing2Asset))).LoadWith(m => m.User)
							 join mr in PPCustomer.MailingRecipients on m.MailingId equals mr.MailingId
							 join sq in PPCustomer.MailingDownloads on mr.MailingRecipientId equals sq.MailingRecipientId into lj
							 from md in lj.DefaultIfEmpty()
							 join sq2 in PPCustomer.Mailing2Assets on m.MailingId equals sq2.MailingId into lj2
							 from ma in lj2.DefaultIfEmpty()
							 where m.MailingId == mailingId
								&& ((mr.MailingRecipientId == mailingRecipientId && m.Password == password)
									|| mr.UserId == CoreInfo.User.UserId
									|| editAllMailings)
							 select new { Mailing = m, Mailing2Asset = ma }).Distinct(); 

var mailing = recordSet.First().Mailing;
This code generates the following SQL statements:

Code: Select all

SELECT DISTINCT t1.`MailingId`, t1.`State`, t1.`CreationDate`, t1.`CreatedByUserId`, t1.`Subject`, t1.`Message`, t1.`Password`, t1.`ExpirationDate`, t1.ts, t4.`Mailing2AssetId`, t4.`MailingId` AS MailingId1, t4.`AssetId`, t4.`ImageFormatId`, t4.`LanguageVersion`, t4.ts AS ts1
FROM tbl_mailings t1
INNER JOIN tbl_mailing_recipients t2 ON t1.`MailingId` = t2.`MailingId`
LEFT OUTER JOIN tbl_mailing_downloads t3 ON t2.`MailingRecipientId` = t3.`MailingRecipientId`
LEFT OUTER JOIN tbl_mailings2assets t4 ON t1.`MailingId` = t4.`MailingId`
WHERE (t1.`MailingId` = :p0) AND (((t2.`MailingRecipientId` IS NULL) AND (t1.`Password` IS NULL)) OR (t2.`UserId` = :p1) OR :p2) LIMIT 1
ParameterName = p0
DbType = Int32
Value = 153
ParameterName = p1
DbType = Int32
Value = 2
ParameterName = p2
DbType = Int64
Value = True

SELECT t1.`MailingRecipientId`, t1.`MailingId`, t1.`UserId`, t1.`EmailAddress`, t1.`RecipientType`, t1.`ReadReceiptTime`, t1.ts, t3.`MailingDownloadId`, t3.`MailingRecipientId` AS MailingRecipientId1, t3.`Mailing2AssetId`, t3.`DownloadTime`, t3.ts AS ts1
FROM (
    SELECT t2.`MailingRecipientId`, t2.`MailingId`, t2.`UserId`, t2.`EmailAddress`, t2.`RecipientType`, t2.`ReadReceiptTime`, t2.ts
    FROM tbl_mailing_recipients t2
    WHERE :np0 = t2.`MailingId`
    ) t1
LEFT OUTER JOIN tbl_mailing_downloads t3 ON t1.`MailingRecipientId` = t3.`MailingRecipientId`
ORDER BY t1.`MailingRecipientId`
ParameterName = np0
DbType = Int32
Value = 153

SELECT t1.UserId, t1.Lastname, t1.Firstname, t1.Tel, t1.Company, t1.Street, t1.Address2, t1.Zip, t1.City, t1.Country, t1.Password, t1.Department, t1.CreationDate, t1.LastLogin, t1.InvalidLoginAttempts, t1.ExpirationDate, t1.EmailAddress, t1.Language, t1.AllowUpdate, t1.UseLDAP, t1.LoginOnlyWithSecurityToken, t1.hideIconShowMore, t1.InternalContactUserId, t1.Comment, t1.State, t1.CDF1, t1.CDF2, t1.CDF3
FROM tbl_users t1
WHERE :np0 = t1.UserId
ParameterName = np0
DbType = Int32
Value = 2
You'll quickly see that the LoadWith "MailingRecipients", the LoadWith "MailingDownloads" and the LoadWith "User" works. But the LoadWith "Mailing2Asset" does not work.

Any idea?
________
Growing marijuana
Last edited by itcore@vit.ch on Thu 17 Feb 2011 05:23, edited 1 time in total.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 29 May 2009 10:31

That's the problem I was talking about.

Post Reply