添加使用实体框架的方法模型实体、框架、模型、方法

2023-09-03 16:31:00 作者:鹤冢

使用实体框架,是有可能的方法添加到对象类? 例如,我有一个客户端映射和我想创建一个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.

 
精彩推荐
图片推荐