0

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; }    
  }
}

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.