在EntityObject和Entity Framework中生成的类之间添加自定义抽象基类 [英] Add custom abstract base class between EntityObject and generated classes in Entity Framework
问题描述
什么是最好的方法来完成这个?
感谢您的帮助。
在考虑删除EntityObject时,EF类的工件不应该通过电线曝光。
请使用 DTO pattern 。
如果您创建新的DTO课程(手动或使用T4模板),并使用类似 AutoMapper 的功能来对数据进行映射
序列化的有效内容将会更简单,更可重用。
I have generated an EDMX project, and I have my data entity classes set up. They all inherit from System.Data.Object.DataClasses.EntityObject. What I would like to do is have another abstract class that inherits from EntityObject, and then my data entity classes inherit from that new class.
What is the best way to accomplish this?
Thank you for any help.
You are right in thinking about removing EntityObject, artifacts of EF classes should not get exposed over the wire.
Please, please, please use the DTO pattern for objects that get passed over the wire.
If you create new DTO classes (manually or using a T4 template) and use something like AutoMapper to map the data back and forth.
The serialized payloads will be far simpler and more reusable.
这篇关于在EntityObject和Entity Framework中生成的类之间添加自定义抽象基类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!