1

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.

2
  • Is there a reason you're doing inheritence and not something simpler like implementing the partial classes? Commented Feb 10, 2010 at 20:24
  • 1
    I am implementing the partial classes. THe reason is that I am passing objects over WCF calls, and I wanted to pass any of these object types into the same call, but have it more restricted that "EntityObject". THe abstract class was a way of doing this since interfaces cannot be serialized. Commented Feb 10, 2010 at 20:26

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I see; passing an abstract class would only be able to pass the parameters defined in that class, and would not have the rest of the data. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.