-
Notifications
You must be signed in to change notification settings - Fork 474
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
"Invalid column name" in nested collection $expand with $top #2026
Comments
Seen this @smitpatel ? Looks very similar to my issue. |
Can confirm this issue. This also happening when expanding multiple levels. The SQL Statement get's wrong alias names. (Bad) workaround: Return IEnumerable instead of IQueryable and use ".ToList()". Then it will get all items from sql and filter in memory (this is working, but not performance wise). But I think this confirms that the sql generation is wrong. |
Also getting this error, its concatenating the ClassName + PrimaryKey for me. Only when using {
"Type": "SQL Exception",
"Exceptions": [
{
"Message": "Invalid column name 'ProductProductId'.",
"Procedure": "",
"LineNumber": 7,
"Source": "Core Microsoft SqlClient Data Provider",
"Server": "mydb.database.windows.net"
},
{
"Message": "Invalid column name 'ProductProductId'.",
"Procedure": "",
"LineNumber": 1,
"Source": "Core Microsoft SqlClient Data Provider",
"Server": "mydb.database.windows.net"
}
]
} StackTrace |
Yep same here. |
Hi! Any workaround? |
same problem |
have same problem
|
Any ETA on when this will be fixed? We are seeing the same error with any $expand that has $top query option. |
I'm seeing this issue when using I get invalid column errors with the columns coming from the |
I'm facing with the same issue with my N:1 tables when i'm using nested The higher versions of the assemblies are also affected:
Framework: .NET Core 3.1 Temporary work-around: Eager loading the references with
|
As another workaround for our nested $expand (A->B->C) issue we have instructed our users to query B with $expand=A,C which works but is not intuitive for the specific use case |
Same issue, but it's reproduced only if |
Hmmm, interesting! Do you have any suggestions then where we can limit the page size? |
I am having the same issue with nested $expand
|
anyone have the solution or not? Please help me out in the code I have shared... |
var departments= new List(); //1. ----------------------I tried this also getting error as in point 2
//2. Getting error here as i have foreign key in Employee Table i.e DepartmentId |
I believe Microsoft has it fixed in EF Core 6. They are not going to make any fixes in prior versions. |
It is not working with Microsoft.EntityFrameworkCore.SqlServer 5.0.10 also. |
@Reena-Patel Can you try 6.x? |
@gathogojr Yes, it is working with 6.x. |
After upgrading to EF Core 3.1 from 2.2 alongside the latest OData 7.3, OData appears to now generate invalid SQL when running an
$expand
on a collection with$top
limiting both the top-level entity and the nested, expanded collection. This issue is likely related to an issue in EF Core though I don't know what LINQ is being passed from OData to cause such an issue.This OData controller method generates an invalid SQL:
When queried via http://localhost:5000/employer?$expand=employees($expand=department;$top=100)&$top=100
Assemblies affected
Local environment
Reproduce steps
Please see this repository for a reproducible sample:
https://github.com/davidyee/CollectionNavigationSample
Model layout:
Expected result
I expected the result with expansions:
Actual result
Exception stacktrace:
Generated SQL as retrieved from SQL Profiler:
It would appear that the three references to
[t]
in[t].[DepartmentId], [t].[EmployerId]
and theINNER JOIN [Department] AS [d] ON [t].[DepartmentId] = [d].[Id]
should actually be[t0]
. Replacing these references from[t]
to[t0]
appears to allow the SQL to execute without error.Additional detail
This issue might be related to the same root cause of dotnet/efcore#17809. Ultimately this issue may actually be an EF Core 3.1 issue although I could only create a reproducible sample in conjunction with an OData controller.
The text was updated successfully, but these errors were encountered: