Monday, February 15, 2010

LINQ to SQL and enabling for WCF use

I have noticed that a lot of people think that they have to create separate data contract classes that are marked with the Data Contract and Data Member attributes. If you want to use the OR Designer generated LINQ to SQL classes as data contracts, you can just modify the Serialization Mode to Unidirectional which adds the attributes to your classes automatically.

I'm a firm believer in having Data Contracts that are as slim as possible to have the best performance over the wire. So if you have a WCF Service that will return just one data aspect of a full customer record from a complex database record, then only having that subset in a separate data contract will be better performing than just letting the entire customer record be serialized and transported over the wire.

No comments:

Post a Comment