0

I've read about Owned Types and Value Conversion (as of Version 2.1). But my case is this, i've a lot of entities that have one or more properties that have static values for example:

public class Entity 
{
    public Gender Gender {get;set;};
}

public enum Gender 
{
    Male,
    Female
}

This is for a web api that is going to be consumed from an external website. So, for those Complex types there is no way to get the string identifier to build a dropdown, or something like that. So i've thought on creating a single table for storing all the static types like this:

public class RefType
{
    public int RefTypeId { get; set; }
    public string GroupName { get; set; }
    public int Key { get; set; }
    public string Value { get; set; }
}

public class Entity
{
    public RefType Gender {get;set;}
    public RefType Type {get;set;}
}

And every entity on the domain of the app is going to have a non-restrictive FK to this table. Is this aproach ok? Or which aproach you recommend me to use?

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
Juanma
  • 905
  • 2
  • 11
  • 25
  • 1
    Have a look at [extension methods for enums](https://stackoverflow.com/questions/15388072/how-to-add-extension-methods-to-enums). – lloyd May 03 '18 at 01:15
  • That is useful, but I'm trying to see if there's a way of avoiding enums. That is going to be like my escape plan – Juanma May 03 '18 at 01:31
  • 1
    If you want to avoid enums then Skeet has [Smart Enumerations](https://codeblog.jonskeet.uk/2007/07/27/smart-enumerations/). – lloyd May 03 '18 at 03:49

0 Answers0