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
I am trying to achieve a TPH approach with discriminators where there are multiple values that share the same type. I have a class structure as follows:
publicclassBaseLineItem{publicintId{get;set;}publicstringLineItemType{get;set;}// Non-null discriminator// Other shared properties}publicclassLineItemType1:BaseLineItem{// Specific logic}publicclassLineItemType2:BaseLineItem{// Specific logic}
The problem I am facing is that previous values specified with the discriminator gets wiped away and the last specified value types will be used instead. I expect that a line item with type == "TYPE1" OR type == "OTHER_TYPE_SIMILAR_TO_1" should both map to LineItemType1. Instead, I am restricted to LineItemType1 == "OTHER_TYPE_SIMILAR_TO_1" and LineItemType2 == "OTHER_TYPE_SIMILAR_TO_2". This can be seen in the query generated by EF Core:
SELECT*FROM [LINE_ITEMS] AS [li]
WHERE [li].[lineitem_type] IN (N'DEFAULT', N'OTHER_TYPE_SIMILAR_TO_1', N'OTHER_TYPE_SIMILAR_TO_2')
Further technical details
EF Core version: 2.2.3
Database Provider: SqlServer (2.2.3)
Operating system: Windows 10 (1809)
IDE: Jetbrains Rider (2019.1 EAP 6)
The text was updated successfully, but these errors were encountered:
Would an explicit list of discriminator values, instead of just one, work for you instead of the wildcard? In other words, you could say that values "A", "B", and "C" will all result in creation of the same type "X".
Perhaps something like the following similar to this:
I am trying to achieve a TPH approach with discriminators where there are multiple values that share the same type. I have a class structure as follows:
And my configuration looks like this:
The problem I am facing is that previous values specified with the discriminator gets wiped away and the last specified value types will be used instead. I expect that a line item with type == "TYPE1" OR type == "OTHER_TYPE_SIMILAR_TO_1" should both map to
LineItemType1
. Instead, I am restricted toLineItemType1
== "OTHER_TYPE_SIMILAR_TO_1" andLineItemType2
== "OTHER_TYPE_SIMILAR_TO_2". This can be seen in the query generated by EF Core:Further technical details
EF Core version: 2.2.3
Database Provider: SqlServer (2.2.3)
Operating system: Windows 10 (1809)
IDE: Jetbrains Rider (2019.1 EAP 6)
The text was updated successfully, but these errors were encountered: