添加使用实体框架的方法模型 [英] Add methods to a model using entity framework

查看:118
本文介绍了添加使用实体框架的方法模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用实体框架,是有可能的方法添加到对象类? 例如,我有一个客户端映射和我想创建一个getAgeFromBirhDate的方法。

With entity framework, is it possible to add methods to an object class ? For example, i have a CLIENT mapping and i would like to create a "getAgeFromBirhDate" method.

推荐答案

是的。这是可能的。实体框架生成分部类的。

Yes. It's possible. Entity Framework generates Partial Classes.

这意味着你可以创建一个包含部分类定义的另一部分(与你的其他方法),另一个文件,一切都将正常工作。

That means you can create another file that contains another portion of the Partial Class definition (with your additional methods) and everything will work just fine.

这篇关于添加使用实体框架的方法模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆