zzzprojects / System.Linq.Dynamic.Core

The .NET Standard / .NET Core version from the System Linq Dynamic functionality.
https://dynamic-linq.net/
Apache License 2.0
1.57k stars 228 forks source link

GroupJoin/SelectMany issue #149

Open rcinge opened 6 years ago

rcinge commented 6 years ago

I am building a left outer join query on EF tables and I am using System.Linq.Dynamic.Core to do it.

When I attempt to enumerate a query that contains a dynamic .GroupJoin() and/or .SelectMany(), I receive an ArgumentException: "The string argument 'ItemName' cannot be empty."

I have seen this issue/question: https://github.com/StefH/System.Linq.Dynamic.Core/issues/142

However my application's data set will be large enough that loading all the table data into memory is not feasible.

I am using Visual Studio 15.6.4 and the following NuGet packages:

"Microsoft.EntityFrameworkCore.Design" Version="2.0.2"
"Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.2"
"Microsoft.EntityFrameworkCore.Tools" Version="2.0.2"
"Newtonsoft.Json" Version="11.0.2"
"NFluent" Version="2.1.1"
"System.Linq.Dynamic.Core" Version="1.0.8.2"

I duplicated the ConsoleApp.NetCore2 test program added another table and several additional tests; see https://github.com/rcinge/TestApps/tree/master/PocApp02

The tests "Dynamic GroupJoin() Query 3a - All EF" and "Dynamic SelectMany() Query 3b - All EF" fail; they should not.

The other tests prove that the join is possible using non-dynamic LINQ and EF DbSets; however the exception is thrown from EF code. Am I doing something wrong with the dynamic method arguments?

StefH commented 6 years ago

It's also difficult for me to deep dive into this specific question.

Did you also try to write the code first by using non-dynamic code?

rcinge commented 6 years ago

Yes, the tests labeled 2a and 2b use non-dynamic (or "real") LINQ entirely, and they succeed.

After your comment, I had the subtle brick-to-the-head realization that I could just mix the "real" and the dynamic methods (all I need is dynamic Where()). Using the combination of methods meets my application's requirements...

I have updated my test program with tests that use the mixed methods, in case someone else encounters this.

ihorlazarenko commented 5 years ago

same issue. GroupJoin in ef core doesn't work. "The string argument 'ItemName' cannot be empty"

ihorlazarenko commented 5 years ago

new ParsingConfig() { RenameParameterExpression = true } fixes issue