Here's a quick conversion pattern you can use if you've got a lot of object conversion going on within your project, especially where databases and web services are involved. Bear in mind that this is essentially what the adapter pattern handles, but doesn't involve any sort of inheritence. It's like a cruder version of that pattern. It's also not as quick to use as a simple linq projection. However, you might want to do that tranposition more than once, so you'd want to stick that logic into a utility method or something similar.
This approach just formalises that utility method and enables you to keep all these kinds of conversions in one place; under one roof, if you will.
My solution involves an interface and (optionally) a utility method. It's handy for when you've got a set of data objects that you want to easily transpose and modify in order to send through a web service call to a client. Even if Linq To Sql (for example) does support such serialisation with WCF services without having to do much work, this often isn't desirable as generally you, as the programmer, want more control over exactly which data is sent across the wire. You might want to do this to guarantee packet sizes, for example, not to mention keeping the interface intact since your domain objects will change.
Read more »