WCF DataContract class with methods
Posted
by
jmlaplante
on Stack Overflow
See other posts from Stack Overflow
or by jmlaplante
Published on 2009-07-15T18:22:22Z
Indexed on
2012/09/28
9:38 UTC
Read the original article
Hit count: 289
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.
© Stack Overflow or respective owner