Description
I seem to have found an issue in the Linq provider.
Consider the following simple query
var contactsQuery_FullQueryInline = from contact in context.ContactSet
join account in context.AccountSet
on contact.ParentCustomerId.Id equals account.AccountId
where contact.ContactId == new Guid("d0269203-9b90-ec11-b400-000d3a224071")
select new
{
Contact = new Contact
{
ContactId = contact.ContactId,
FirstName = contact.FirstName,
MiddleName = contact.MiddleName,
LastName = contact.LastName,
BirthDate = contact.BirthDate,
},
Account = new Account
{
AccountId = account.AccountId,
Name = account.Name
}
};
var results_Orig = contactsQuery_FullQueryInline.FirstOrDefault();
This works just fine, as you'd expect. We get the details of our contact & some info on the joined account.
However, if we're selecting a load of properties (or if we have multiple queries looking for the same fields), you'd ideally want to split the selections out into their own selector functions.
Aiight, easy enough ...
var contactsQuery = from contact in context.ContactSet
join account in context.AccountSet
on contact.ParentCustomerId.Id equals account.AccountId
where contact.ContactId == new Guid("d0269203-9b90-ec11-b400-000d3a224071")
select new
{
Contact = SelectContactDetails(contact),
Account = SelectAccount(account)
};
var results = contactsQuery.FirstOrDefault();
private static Contact SelectContactDetails(Contact contact)
{
return new Contact
{
ContactId = contact.ContactId,
rkv_PortalGuid = contact.rkv_PortalGuid,
FirstName = contact.FirstName,
MiddleName = contact.MiddleName,
LastName = contact.LastName,
BirthDate = contact.BirthDate,
};
}
private static Account SelectAccount(Account account)
{
return new Account
{
AccountId = account.AccountId,
Name = account.Name
};
}
You'd expect that'd be the end of it. But the problem is that this only kinda works.
The contact details are selected as expected. The account properties however are included in the 'Attributes' list, but they're all 'NULL'.
CURRENT BEHAVIOR: Joined entity information is not selected by the DataVerse queryprovider.
EXPECTED BEHAVIOR: Joined entity details are selected by the DataVerse queryprovider.