I have a LINQ to SQL class (dbml) representing some tables in a database. I have added a "calculated field" of sorts by extending the partial class of one of the tables (Dwelling) with a new property (DwellingCode); this property takes the values of several database fields in the Dwelling table and generates a string.
So far, everything works fine; I can get this calculated field to display properly in bound controls in web pages etc. The problem is I also have a SOAP web service that returns a Dwelling object. When the Dwelling object gets serialized into XML, the DwellingCode is not included with the rest of the "real" database fields.
What do I need to do to get the DwellingCode property to serialize with the rest of the database fields? Based on some googling, I've tried adding [DataMember] and [DataMamberAttribute] to the DwellingCode property and [DataContract] and [Serializable] to the partial class but nothing seems to work.
public partial class Dwelling
{
public string DwellingCode
{
get
{
// code to concatenate fields here
}
}
}