-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
TPH Inheritance and filtering problem #62
Comments
So it's adding a filter against the "TenantId" column on the EditionFeatureSession table? Is that generating a SQL error then since the column TenantId does not exist in table EditionFeatureSession? I have never seen a filter wrongly applied to an entity before... |
Oh, this is TPH. That means both entities are in the same table. |
And also I saw it in unit tests, not tested against SQL Server to see generated SQL. I can also do it if this is not enough. |
I'll take a look at this in more detail. But at first glance, this is going to be a difficult situation to handle - if it's possible at all. That filter would need to know to automatically include a condition that matches on a discriminator value. And the only immediate information I have to go on is "IMustHaveTenant" which obviously has no knowledge of the entity being TPH, let alone the column name of the discriminator and what value should be used. At this point (5 minutes of research), I don't know if EF exposes enough information for me to figure this out. Especially to the level of determining the discriminator values that would be needed. 2 possible workarounds that come to mind:
I'll see if I can come up with a better solution but it may take some time. |
Thank you for your comments. I'll try workarounds and write here again. |
Hi again, I changed my filter definition like that: modelBuilder.Filter(AbpDataFilters.MustHaveTenant, (IMustHaveTenant t, int tenantId) => t.TenantId == tenantId || (int?)t.TenantId == null, 0); and it worked! It seems strange to cast int to int? but it's null for EditionFeatureSetting entities, and it works. Thank you much for leading me to the right direction. |
Glad to hear you found a solution. I'll keep this issue open until I have a chance to look at it closer. Maybe I can come up with a cleaner solution. |
Changed my filter definition like that gives no warning at all:
|
I have this inheritance:
My filtering interface is
IMustHaveTenant
. I defined filter as shown below:All is good. But, when I query EditionFeatureSettings from database, it adds TenantId filter to the query, and thus I can not get any EditionFeatureSettings. Actually, filtering should be only applied for TenantFeatureSetting, since only it defines TenantId. So, when I query EditionFeatureSettings, it should not apply any filtering, but it does.
Thanks a lot.
The text was updated successfully, but these errors were encountered: