1

I have some business objects and some very similar corresponding data contract objects for getting data across the wire via WCF service.

What mechanism should I use to get populated data contract objects from business objects?

In an ideal world, should the data contract layer know about the business layer?

or

Should the business layer know about the data contract layer?

or

Should there be another mapping layer that has static methods like GetDataContractFromBusinessObject?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
MStodd
  • 4,716
  • 3
  • 30
  • 50
  • Refer http://stackoverflow.com/questions/11681475/wcf-message-data-contract-dto-domain-model-and-shared-assemblies/15828836#15828836 that explains (with an example) how the clients will break if you don't have a transformation layer. – LCJ Apr 12 '13 at 06:05

2 Answers2

2

I am a big fan of the "mapping layer with static methods" technique you mention. Then, your business objects and data contracts don't depend on each other either way.

benjy
  • 4,664
  • 7
  • 38
  • 43
0

I often will add a derived class to handle data consumption from a specific backing store in my business layer.

Another option is to an interface data layer representation that the business class understands. And then have your data layer implement that interface. I prefer this method as it is much simpler to have you business layer interact with an abstracted version of your data layer then having your data layer understand your business objects.

rerun
  • 25,014
  • 6
  • 48
  • 78