I need some guidance on what is the best way to define DataContracts for following scenario : 1. I have 2 web methods one to upload the raw data 2. This data is used on the server for certain calculations. i.e. An item has a set of calculations, 3. So my entity design is such that Item entity has collection of Calculation entities. The collection is not marked as a DataMember. 4. The GetItemDetails method returns each item with it's collection of calculations. 5. I have ended up defining 2 differet DataContracts for Upload and GetItemDetails operations because Item is my main entity which is used in all my business logic operations but its collection of calculations is data that gets generated at server side and must be returned on demand (GetItemDetails ). Since it's processing data it seems inappropriate to expose it at the time of Upload as no input is expected in the calculation collection. 6. In my GetItemDetails method, I use 'Item' entity and load collection of items with resp. calculation collections and then translate it into my output datacontract which has item and collection both exposed.
This approach has the disadvantage of having to maintain 2 data contracts for the same Entity representation. I tried to search for option to dynamically adding DataMember attribute on the Calculation collection for GetItemDetails method with no success. I hope the scenario is clear. My question is what is the best way to define data contracts in such scenarios so that client doesn't have to deal with 2 different proxy classes for representing the same entiy for Upload and Get. Will it be a correct solution if same entity is used for both so that my upload contract exposes (and then ignores any input in) Calculation collection even though user is not expected to provide it to my Upload operation ?
I will appreciate any help on this.