Reputation: 385
Using C#, ASP .Net MVC 4, Entity Framework 5 and Database First. How can I override a property or add a new property to a model class? Below you can see the "Type" as a Byte, but I can't display the byte to the users and I want to display a friendly name. The Type description is not in the database, it is stored in a dictionary.
namespace Cntities
{
public partial class myClass
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public byte Type { get; set; }
}
}
Upvotes: 0
Views: 1390
Reputation: 2734
Since the class is a partial you can expand and add your own properties and methods just ensure its defined in the same location as your current partial file.
namespace Cntities
{
public partial class myClass
{
public string DisplayValue{ get {
return "Formated"; // An example
}
}
}
Take a look at http://msdn.microsoft.com/en-us/library/wa80x488.aspx
Upvotes: 1