這如何作爲WCF服務工作?WCF通用類
public class BusinessObject<T> where T : IEntity
{
public T Entity { get; set; }
public BusinessObject(T entity)
{
this.Entity = entity;
}
}
public interface IEntity { }
public class Student : IEntity
{
public int StudentID { get; set; }
public string Name { get; set; }
}
我要揭露的BusinessObject的<牛逼>類和所有繼承了WCF服務的IEntity接口的類。
我的代碼是使用C#.NET Framework 4.0構建在Visual Studio 2010 Pro中。
但是學生不是T型的唯一類型。我有許多實體類。 –
我現在明白了,但是我需要爲所有實體類添加DataContract和DataMember屬性嗎? –
WCF的面向服務的性質不會允許這樣做。從客戶角度思考。到客戶打電話時,合同應該是衆所周知的。 – chandmk