alansiqueira27
alansiqueira27

Reputation: 8506

What's a good way for entity class inside a WCF?

I have a entity class inside a WCF project. There are 2+ services (.svc) that use that entity class. When the client side access those services, and somehow the client access the 2 services and need to work with both entities (like comparing..). But even if the entities are the same, they are not compatibles at client side.

One way is to do DTO = Data Transfer Object. Is there any better solution? Thank you.

Upvotes: 1

Views: 151

Answers (1)

John Saunders
John Saunders

Reputation: 161773

If you don't mind coupling your client and server, then you can share the types between the two. Place the entities into their own class library, which the service will use.

Then, on the clients, add a reference to this same class library. In the "Advanced" tab of the "Add Service Reference" dialog, make sure that "Share all types" is checked.

Upvotes: 3

Related Questions