Open Closed

Suite, property that is array of enum? Possible? best options? #5224


User avatar
0
chauey created

Is it possible with the suite to create a property that is an array of a custom enum? if so how? what are the best workarounds/options/recommendations if we want a property to have an array of an enum? In the suite, I only see we can choose "enum" and we put in a file path to the enum CS file.

(BTW, I also ran into this other problem in the following link but perhaps redoing and cleaning the solution fixed it. https://support.abp.io/QA/Questions/5106/Abp-Suite-Domain-Service-Generation-Errors)

  • ABP Framework version: v7.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

3 Answer(s)
  • User Avatar
    0
    nlachmuthDev created

    Hi there,

    If you want to store multiple enum values inside one property i would recommend using the [Flags] attribute for your custom enum. With enum flags you can store multiple values inside a normal enum property. You can also check if multiple values are store inside that property, so you would not need an array of enum property.

    Here is a deep dive into enum flags in c#: https://code-maze.com/csharp-flags-attribute-for-enum/

    Please let me know if that helps.

  • User Avatar
    0
    chauey created

    Hi there,

    If you want to store multiple enum values inside one property i would recommend using the [Flags] attribute for your custom enum.
    With enum flags you can store multiple values inside a normal enum property. You can also check if multiple values are store inside that property, so you would not need an array of enum property.

    Here is a deep dive into enum flags in c#: https://code-maze.com/csharp-flags-attribute-for-enum/

    Please let me know if that helps.

    Interesting, thx. Would we need to manually modify and typescript/Angular codes for this or would any of the code gen get this correctly?

  • User Avatar
    0
    nlachmuthDev created

    Unfortunatly you have to manualy modify the angular components since they allow only selecting one value for the enum.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on June 13, 2025, 11:37