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

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

问题描述

使用实体框架,是否可以向对象类添加方法?
例如,我有一个CLIENT映射,我想创建一个getAgeFromBirhDate方法。

解决方案

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



这意味着您可以创建另一个包含Partial Class定义的其他部分的文件(使用其他方法),一切都将正常运行。


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天全站免登陆