Picture, if you will, the following scenario:
- BusinessObjects.dll contains a class "BusinessObject"
- WinClient references BusinessObjects.dll
- Web Service references BusinessObjects.dll
Web Service has a method:
public BusinessObject GetBusinessObject()
{
BusinessObject result = new BusinessObject;
result.Name = "MyBusinessObject";
return result;
}
This method is called by the WinClient.
When I add the reference to WebService, then a proxy class will be created. So if I access BusinessObject from WinClient like so:
BusinessObject bObj = service.GetBusinessObject();
then bObj is NOT the same object in BusinessObject.dll, but is actually the proxy.
There is a work-around as documented here - http://ryanfarley.com/blog/archive/2004/05/26/737.aspx
My question - is this a good idea? Or should objects returned from a service ALWAYS be treated as simple DTOs? So if we want the logic then we should copy the values into the REAL businessObject. But what about the performance hit on doing this - should I worry about it?
Any feedback welcome, thanks.