Open Closed

Type discrimination at controller level #5267


User avatar
0
nailgoksel created

Hi!,

I would like to discriminate some of the properties of controller parameter. For example, assume that I have a controller parameter called ClassX

public class ClassX
{
    public DetailDefinition Definition { get; set; }
    public IDetails Details { get; set; }
}

Typically I want Details to be differ based on the information of "Definition" property. Using this class in ABP, we get deserialization errors since Details property is an Interface type. Looking .NET documentations it seems this approach can be done using "Type Discrimination" practices like defined in https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism?pivots=dotnet-7-0#polymorphic-type-discriminators.

Since my scenario needs to be done at controller level, I want to know whether above approach is possible or not.

  • ABP Framework version: 7.x

1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Have you tried this without ABP? if it can work in MVC app then the same will work for ABP

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11