问题描述
我已经生成了一个EDMX项目,我已经建立了我的数据实体类。它们都从System.Data.Object.DataClasses.EntityObject继承。我想做的是从EntityObject继承的另一个抽象类,然后我的数据实体类继承自该新类。什么是最好的方法来完成这个?
感谢您的帮助。
在考虑删除EntityObject时,EF类的工件不应该通过电线曝光。
请使用。
如果您创建新的DTO课程(手动或使用T4模板),并使用类似的功能来对数据进行映射
序列化的有效内容将会更简单,更可重用。
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中生成的类之间添加自定义抽象基类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!