Skip to content

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

Closed
@david-garcia-garcia

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions