dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.8k stars 3.2k forks source link

whats the replacement for ColumnExpression.Table in v9? #35165

Closed SimonCropp closed 1 day ago

roji commented 1 day ago

ColumnExpression no longer references its table - it only has the table and column aliases, and in that sense, accurately represents the actual SQL syntactic element (which is e.g. t.Id). The previous system meant that our expression tree was in fact a graph (since the table was referenced by both the SelectExpression and columns), and caused lots of referential integrity bugs as references were not kept in sync etc.

To get the table referenced by a ColumnExpression, an expression visitor must track the tables in scope as it visits SelectExpression, and then use that state information to resolve the ColumnExpression's table alias to the TableExpressionBase it refers to.

Does that make sense? And also, how were you using ColumnExpression.Table previously?

SimonCropp commented 1 day ago

@roji thanks for the clarrification.

to get the table referenced by a ColumnExpression, an expression visitor must track the tables in scope as it visits SelectExpression, and then use that state information to resolve the ColumnExpression's table alias to the TableExpressionBase it refers to.

awesome. that got me moving forward

And also, how were you using ColumnExpression.Table previously?

we have some code that forces tolists to have an orderby in certain circumstances. similar to the "filter must have an order by" warning already in ef

roji commented 23 hours ago

Thanks for the context @SimonCropp, don't hesitate to ping me back for any further questions etc.