views:

29

answers:

2

Hi, I have an autogenerated class, which I want to partially reuse as DataContract. Since the class is periodically auto-regenerated, I wouldn't like to add DataMemberAttribute to its properties, because it will be lost. What are the alternatives? Can I define which properties are going to be serialized programmatically or, may be, via a partial class?

Thanks!

A: 

The class is generated by Linq toSQL. Thank you!

Vika
Apparently LinqToSql enables to define serialization mode for WCF. But when the DataContext is regenerated from a DB, the property will get lost too.
Vika
A: 

You can add XmlAttributes at runtime with the XmlAttributeOverrides class but I'm not sure if you can do the same with DataMemberAttribute, have not come across an equivalent of XmlAttributeOverrides..

theburningmonk