score:1

Accepted answer

if you're willing to use wcf (for the webservice and the client) you can decorate your linq2sql generated classes with the [datacontract] and [datamember] attributes.

check the following links for some guidance:

score:2

the linq-to-sql classes can be used with datacontractserializer (for wcf) easily enough (you need to enable the serialization property in the designer, though). with this in place, you should be able to share the data assembly with the client. as long as you don't use the data-context, the objects themselves should be well behaved (just disconnected - so no lazy loading).

the trick is that you need to re-use these types (from the existing assembly) in your serialization code. if you are using wcf, you can do this with svcutil /r, or via the ide.

that said though; it is often cleaner to maintain separate dto classes for these scenarios. but i'm guilty of doing it the above way on occasion.


Related Query

More Query from same tag