Extending the wireframe model of an object

I want to extend the entity framework model with the temporany attribute. I only need this in mvc form. I do not need to save it in db.

How can i do this?

+3
source share
1 answer

Create a partial class for the object you want to extend

eg.

//must be in the same namespace as the Customer entity in the model
public partial class Customer
{
     public string MyProperty{get;set;}
}

This property will be disabled, and you will be able to fill it with data after running a query or materialization.

OR

Create a wrapper class for your entity that displays both the unmapped property and the associated properties, the properties you need in the view.

+5
source

Source: https://habr.com/ru/post/1744756/


All Articles