I\'m trying to build a generic solution to the problem of enums with EF 4.1. My solution is basically a generic version of How to fake enums in ef 4. The enum wrapper class
based on Henrik Stenbæk answer. assigning is working fine
category.ChildSortType = CategorySort.AlphabeticOrder
but comparing the wrapper to its enum doesn't work.
if(category.ChildSortType == CategorySort.AlphabeticOrder)
{
}
the following operator should be added to the abstract class
public static implicit operator TEnum(EnumWrapper w)
{
if (w == null)
return default(TEnum);
else
return w.EnumVal;
}