Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linq query -> JOIN -> Select -> All selected properties 'null' #382

Open
VanPuyveldeKevin opened this issue Jul 3, 2023 · 3 comments
Open
Labels
Server Platform API Fix\Change Cannot be fixed client side, requires server side fix

Comments

@VanPuyveldeKevin
Copy link

VanPuyveldeKevin commented Jul 3, 2023

I seem to have found an issue in the Linq provider.
image

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.
image

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'.
image

CURRENT BEHAVIOR: Joined entity information is not selected by the DataVerse queryprovider.
EXPECTED BEHAVIOR: Joined entity details are selected by the DataVerse queryprovider.

@VanPuyveldeKevin
Copy link
Author

VanPuyveldeKevin commented Jul 12, 2023 via email

@chironh
Copy link

chironh commented Jul 12, 2023

I deleted my comment right after initial posting it because I re-read the original message and I saw missed an important part where the query succeeded without using methods.

@MattB-msft
Copy link
Member

I know I'm way behind on responding to this one, Sorry about that.

The LINQ provider is in somewhat of a limbo state right now. I had fowarded this over to them to investigate but they have declined it at the moment. What I would suggest you do here is provide this feedback on the doc link for the LINQ provider to help raise some visibility on this.

@MattB-msft MattB-msft added the Server Platform API Fix\Change Cannot be fixed client side, requires server side fix label Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Server Platform API Fix\Change Cannot be fixed client side, requires server side fix
Projects
None yet
Development

No branches or pull requests

3 participants