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
That might be the best option for enums, but another idea would be to just use constants instead of enums:
static void Main(string[] args)
{
Console.WriteLine("There are {0} red chicken sandwiches.",
sandwiches.ChickenSandwiches
.Where(s => s.Color == Color.red)
.ToArray().Length);
}
public struct Color
{
public const int red = 1;
public const int green = 2;
}
public class ChickenSandwich
{
public ChickenSandwich()
{
}
public int ID { get; set; }
public string Name { get; set; }
public int Color { get; set; }
}
public class Sandwiches : DbContext
{
public DbSet ChickenSandwiches { get; set; }
}