-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Support join with enumerable on client #17031
Comments
|
Sure I would expect sth like this: SELECT e.* FROM [table] e It should be used to select multiple entities by a 3 column composite key |
That is invalid SQL in SqlServer. |
I executed this command on our local SQL instance and it worked as expected. I will try it again be be it is just a Syntax error. I wrote the Statement by Hand so maybe thats why it is invalid Syntax SELECT * This is where I got it from it is valid SQL Server Statement |
Interessting idea for JOIN with smaller collections.
After that we need a custom method/expression to generate the SQL. The easiest way would probably be the use of
Now, we could join with the Don't know if it helps in your use case. But I'm usually working with big collection having hundreds or thousands or records so I'm using
|
This is now possible as part of #30426, by packing the local collection to JSON (or an array on PG). For example, see this test in our test suite: LINQ: public virtual Task Column_collection_Join_parameter_collection(bool async)
{
var ints = new[] { 11, 111 };
return AssertQuery(
async,
ss => ss.Set<PrimitiveCollectionsEntity>()
.Where(c => c.Ints.Join(ints, i => i, j => j, (i, j) => new { I = i, J = j }).Count() == 2),
entryCount: 1);
} SQL: @__ints_0='[11,111]' (Size = 4000)
SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[String], [p].[Strings]
FROM [PrimitiveCollectionsEntity] AS [p]
WHERE (
SELECT COUNT(*)
FROM OPENJSON([p].[Ints]) WITH ([value] int '$') AS [i]
INNER JOIN OPENJSON(@__ints_0) WITH ([value] int '$') AS [i0] ON [i].[value] = [i0].[value]) = 2 |
Duplicate of #30426 |
Describe what is not working as expected.
Why EF Core cant translate this query, its is a simple join on multiple columns and looks the same as in many tutorials for EF.
Is this not implemented yet and the tutorials are related to ef6 or what's wrong with this implementation?
Is there any way to solve this kind of Problem in EF Core?
Further technical details
EF Core version: 2.2.6.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system:
IDE: (e.g. Visual Studio 2019)
The text was updated successfully, but these errors were encountered: