WCF DataContract class with methods
- by jmlaplante
This is more of a philosophical/best-practice sort of question rather than a technical problem.
Are there any strong arguments against writing a DataContract class with methods that are to be used server-side only? Or what about additional properties that are not decorated with the DataMember attribute?
For example:
[DataContract]
public class LogEntry
{
[DataMember]
public string Message { get; set; }
[DataMember]
public string Severity { get; set; }
public string SomeOtherProperty { get; set; }
...
public void WriteToDatabase()
{
...
}
}
Not doing it seems like an awful lot of extra work that I would prefer to avoid, although using extension methods could make it easier.
But, as a good developer, I am wondering if it is bad practice to do so.