Hi Guys,
Suppose i have the following 2 SQL tables:
Foo
Column DataType
---------------------------
Title NVARCHAR(20)
Body NVARCHAR(MAX)
FooTypeId TINYINT
FooType
Column DataType
--------------------------
FooTypeId TINYINT
Name NVARCHAR(10)
Now, im using Entity Framework 4.0 with a custom data context and POCO implementation.
How do i map this on the designer, and my POCO's?
Do i have to create a POCO property (of type byte i assume) called "FooTypeId", then i expose ANOTHER property of my enum type?
Ie.
public class Foo
{
public byte FooTypeId { get; set; } // for ORM - do i need this??
public FooType FooType // for most querying operations
{
get
{
return (FooType)this.FooTypeId;
}
set
{
this.FooTypeId = (int)value;
}
}
}
public enum FooType
{
Blah = 1,
Foo = 2,
Bar = 3
}
At the moment, i do not even have the FooType table on my designer, as i figured i can try and "express" this as an enumeration from the actual FooTypeId on the Foo property. Or am i supposed to create a "Navigational Property" on the mapper, then define that in my POCO?
I've read threads from a few years back (EF1) saying "Enums are not supported in EF", is this still the case with EF4? If it is, is what im doing right?
I'm kind of lost here, some guidance would be greatly appreciated!