开发者

extending an entity framework model

开发者 https://www.devze.com 2022-12-29 14:36 出处:网络
i want extend an entity 开发者_高级运维framework model with a temporany attribute. I need it only in a mvc form. I don\'t need save it in the db.

i want extend an entity 开发者_高级运维framework model with a temporany attribute. I need it only in a mvc form. I don't need save it in the db.

How can i do it?


Create a partial class for the entity you want to extend

e.g.

//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 unmapped and you can fill it with data after you run a query or on materialization.

OR

Create a wrapper class for your entity which expose both the unmapped property and the mapped properties the properties you need in the view.

0

精彩评论

暂无评论...
验证码 换一张
取 消