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

[Bug] Incorrect Nullable<> parsing #111

Closed
MakarovSoftware opened this issue Oct 31, 2017 · 1 comment
Closed

[Bug] Incorrect Nullable<> parsing #111

MakarovSoftware opened this issue Oct 31, 2017 · 1 comment
Assignees
Labels

Comments

@MakarovSoftware
Copy link

MakarovSoftware commented Oct 31, 2017

Here is a problem, that I've got starting from my previous question. I have two types with two properties - "Guid" and "Guid?". And trying to Join em.

In a Join method you call DynamicQueryableExtensions.CheckOuterAndInnerTypes() method, that must check and convert not-a-nullable part to Nullable if needed.

But in fact after parsing Lambda, Method outterLambda.Body.Type returns Anonymous type. That is always not-a-nullable one.

Type example: {Name = "<>f__AnonymousType2761" FullName = "<>f__AnonymousType2761[[System.Nullable`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}

And so your library see that there is two different and not-nullable object. I'll try to make a demo project for you.
Nullable-Demo.zip

@StefH StefH self-assigned this Nov 1, 2017
StefH added a commit that referenced this issue Nov 1, 2017
@StefH
Copy link
Collaborator

StefH commented Nov 1, 2017

When using a normal LINQ query, you need to cast to nullable Guid, else it won't compile.
Like:

var query = peopleQuery.Join(petsQuery, people => new { firstKey = (Guid?) people.Id }, pet => new { firstKey = pet.OwnerId }, (inner, outer) => new { pet = inner, person = outer })
                .Select(res => new { personName = res.person.Name, petName = res.pet.Name });

In dynamic LINQ, you need to do the same:

var dynamicQuery2 = dynamicPeopleQuery2.Join(dynamicPetsQuery2, "new (Guid?(Id) as firstKey)", "new (OwnerId as firstKey)", "new (inner as pet, outer as person)")
                .Select("new (person.Name as personName, pet.Name as petName)");

There is no automatic code which can try to make two dynamic objects the same, you have to define what you want.

@StefH StefH closed this as completed Nov 1, 2017
@StefH StefH removed the question label Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants