timabell / ef-enum-to-lookup

Generates lookup tables from enum references in Microsoft Entity Framework 6.1
https://www.nuget.org/packages/ef-enum-to-lookup
69 stars 29 forks source link

Include Display/Description attribute data in a new column #33

Open sveinhelge opened 9 years ago

sveinhelge commented 9 years ago

Would like to have the ability to have Description as column.

The table would then look like this: Id Name Description

It could be implemented as a setting. var enumToLookup = new EnumToLookup(); enumToLookup.AddDescriptionColumn = true;

Since [Description("some name")] is used to override name we might need to add new attribute for this or redefine the usage.

timabell commented 9 years ago

+1 good idea. This would make it possible to add more detail to things that access the db directly.

A pull request for this would be welcome.

I'll hold off actually releasing it till v2 as it's a significant change to the schema and would need some thought in how to handle the transition for existing installations.

I don't think I'd make it configurable, it would just always add it. Allowing the variation increases the complexity of what would have to be supported.

jasonp123 commented 9 years ago

Instead of using [Description("description")] could we use [System.ComponentModel.DataAnnotations.Display(Name="new name", Description="new description")]?

When using the ASP.NET MVC html helper @Html.EnumDropDownListFor(m=>m.MyEnum) it uses the Display("Name="") text to populate the drop down. (https://msdn.microsoft.com/en-us/library/system.web.mvc.html.selectextensions.enumdropdownlistfor(v=vs.118).aspx)

This could also allow the use of a Resource class as well

timabell commented 9 years ago

Great minds think alike @jasonp123 - take a look at the linked pull request discussion

jasonp123 commented 9 years ago

ha.. I'm new.. ignore me :-)