You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are having multiple entities with the same query filter in the form of
boolIsArchived
Our desired behavior for these entities is, that once they are archived, they are not displayed to the user anymore, when queried as the root entity.
The reason we chose not to delete these entities is, that once they are related to other root entities, they should still be visible (regardless of them being archived or not), so that aggregates that were created before the nested entity was archived, remain unchanged.
I have prepared an example to showcase the (from our perspective) unwanted behavior.
And this is the "test case" for our example. We create two units and four measurements and assign units to these measurements. Afterwards we change one unit to be archived. Then we query all measurements.
Querying the measurements now, only yields the 2 entries, that are not related to the archived unit, even though the measurements that are related to the archived unit themselves are not archived.
Which makes sense in regard to the generated sql statement, which applies the query filter to the inner join as well as to the outer/main query.
SELECT [m].[Id], [m].[IsArchived], [m].[UnitId], [m].[Value], [t].[Id], [t].[IsArchived], [t].[Title]
FROM [Measurements] AS [m]
INNER JOIN (
SELECT [u].[Id], [u].[IsArchived], [u].[Title]
FROM [Units] AS [u]
WHERE [u].[IsArchived] <> CAST(1ASbit)
) AS [t] ON [m].[UnitId] = [t].[Id]
WHERE [m].[IsArchived] <> CAST(1ASbit)
Ignoring query filters via
.IgnoreQueryFilters()
is not an option for us either, because it would also yield measurements that are 'legitimately' archived.
So our desired behavior would be to remain the inner join (since we want the archived nested entities to be included) but not apply the query filter to the inner select query.
The related issue #11691 describes a similar behavior, and @smitpatel mentioned that it is fixed with 3.1, but either it isn't or (more likely) we have a misunderstanding of what the desired/implemented behavior is like.
So my question is, are we doing things wrong? Is there a way to achieve our desired behavior with global query filters or do we need to manually perform this filtering on all of our calls (which would be kinda sad, because i really like this feature).
Further technical details
EF Core version: 3.1.3
Database provider: Microsoft.EntityFrameworkCore.SqlServer 3.1.3
Target framework: .NET Core 3.1 (SDK: 3.1.201)
Operating system: macOS Catalina 10.15.4 (also tested on Windows 10)
IDE: Visual Studio Code 1.44.2
The text was updated successfully, but these errors were encountered:
Related to #11691
We are having multiple entities with the same query filter in the form of
Our desired behavior for these entities is, that once they are archived, they are not displayed to the user anymore, when queried as the root entity.
The reason we chose not to delete these entities is, that once they are related to other root entities, they should still be visible (regardless of them being archived or not), so that aggregates that were created before the nested entity was archived, remain unchanged.
I have prepared an example to showcase the (from our perspective) unwanted behavior.
Steps to reproduce
As an example we have these 2 classes.
DbContext configuration example
And this is the "test case" for our example. We create two units and four measurements and assign units to these measurements. Afterwards we change one unit to be archived. Then we query all measurements.
Querying the measurements now, only yields the 2 entries, that are not related to the archived unit, even though the measurements that are related to the archived unit themselves are not archived.
Which makes sense in regard to the generated sql statement, which applies the query filter to the inner join as well as to the outer/main query.
Ignoring query filters via
is not an option for us either, because it would also yield measurements that are 'legitimately' archived.
So our desired behavior would be to remain the inner join (since we want the archived nested entities to be included) but not apply the query filter to the inner select query.
The related issue #11691 describes a similar behavior, and @smitpatel mentioned that it is fixed with 3.1, but either it isn't or (more likely) we have a misunderstanding of what the desired/implemented behavior is like.
So my question is, are we doing things wrong? Is there a way to achieve our desired behavior with global query filters or do we need to manually perform this filtering on all of our calls (which would be kinda sad, because i really like this feature).
Further technical details
EF Core version: 3.1.3
Database provider: Microsoft.EntityFrameworkCore.SqlServer 3.1.3
Target framework: .NET Core 3.1 (SDK: 3.1.201)
Operating system: macOS Catalina 10.15.4 (also tested on Windows 10)
IDE: Visual Studio Code 1.44.2
The text was updated successfully, but these errors were encountered: