Starts in:
2 DAYS
1 HR
1 MIN
48 SEC
Starts in:
2 D
1 H
1 M
48 S
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.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06