Consider the following simple example:
[DataContract("{0}Base")]
public class Base<T> where T : Entity<T>
{
// Common methods & properties. No WCF exposed properties
}
[DataContract]
public class Employee : Base<Employee>
{
// WCF exposed properties
}
The base class Base has no properties of interest to the WCF service consumers, but WCF forces me to also annotate the Base class with a [DataContract] attribute. This essentially shows up on the service client as Employee : EmployeeBase
with EmployeeBase
being an empty class with no properties.
I do not want to expose the Base<T>
class to the service in this way, so what are my options?
Base<T>
. Is this possible? How?Thanks.
Each class in hiearchy has to be serializable / DataContract. If you don't want to expose hiearchy you have to use DTO or you can try to implement IDataContractSuroggate for your Employee class.