开发者

extending an entity framework model

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜