Am using EntityFramework and have a LinkStatusID column which is a tinyint, which gets generated into a byte in C#.
public enum LinkStatus
{
Added = 0,
Deleted = 1
}
however this gives:
a.LinkStatusID = (byte)Enums.LinkStatus.Deleted;
is there a more elegant way to structure this?
EDIT2 for LastCoder:
public enum LinkStatus : byte
{
Added = 0,
Deleted = 1
}
var blah = Enums.LinkStatus.Added;
var ty = blah.GetType();
var blah2 = (byte)Enums.LinkStatus.Added;
var ty2 = blah2.GetType();
This doesn't work (as I expected) however the first answer here explains why.
EDIT3: EF isn't the only way this sln gets to the DB, so I'm keen to keep the Enums explicit in the code. Thanks for EF5 Enum suggestions!
public enum LinkStatus : byte
Will avoid the explicit cast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With