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

Cannot GroupJoin when source is Linq-To-Entities #204

Closed
david-garcia-garcia opened this issue Sep 23, 2018 · 2 comments
Closed

Cannot GroupJoin when source is Linq-To-Entities #204

david-garcia-garcia opened this issue Sep 23, 2018 · 2 comments

Comments

@david-garcia-garcia
Copy link
Contributor

david-garcia-garcia commented Sep 23, 2018

I am struggling to make an outter join using this library.

After some digging I found that GroupJoin is passing the inner collection as a Constant Expression, where it should honor the original one:

src/System.Linq.Dynamic.Core/DynamicQueryableExtensions.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/System.Linq.Dynamic.Core/DynamicQueryableExtensions.cs b/src/System.Linq.Dynamic.Core/DynamicQueryableExtensions.cs
index 0a32c0d..7a487fe 100644
--- a/src/System.Linq.Dynamic.Core/DynamicQueryableExtensions.cs
+++ b/src/System.Linq.Dynamic.Core/DynamicQueryableExtensions.cs
@@ -697,7 +697,7 @@ namespace System.Linq.Dynamic.Core
                typeof(Queryable), nameof(Queryable.GroupJoin),
                new[] { outer.ElementType, innerType, outerSelectorLambda.Body.Type, resultSelectorLambda.Body.Type },
                outer.Expression,
-                Expression.Constant(inner),
+                inner.AsQueryable().Expression,
                Expression.Quote(outerSelectorLambda),
                Expression.Quote(innerSelectorLambda),
                Expression.Quote(resultSelectorLambda)));

I can see other extension methods such as Join use inner.AsQueryable().Expression instead of Expressoin.Constant(...).

When using Expression.Constant() EF will complain that it cannot materialize the object.

@StefH
Copy link
Collaborator

StefH commented Sep 24, 2018

If you think this is a bug, you can create a PR + additional unit-tests to fix this.

Also the example console application can be updated to reflect this situation.

@david-garcia-garcia
Copy link
Contributor Author

Solved in the last release! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants