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