由于性能调整,我想只返回必要的属性。有没有可能/解决方法?伪/示例代码理解:
[DataContract]
public interface IMemberOverview
{
[DataMember]
public int Id { get; set; }
[DataMember]
public string Name { get; set; }
}
[DataContract]
public interface IMemberDetail
{
[DataMember]
public int Id { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Status { get; set; }
[DataMember]
public string Infos { get; set; }
}
public class Member : IMemberOverview, IMemberDetail
{
public int Id { get; set; }
public string Name { get; set; }
public string Status { get; set; }
public string Infos { get; set; }
}
和服务:
[OperationContract]
[WebInvoke(
Method = "GET",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "ListMembers")]
[KnownType(typeof(Member))]
public List<IMemberOverview> ListMembers()
{
return MemberDAO.Instance().GetAll();
}
[OperationContract]
[WebInvoke(
Method = "GET",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "Member/{idString}")]
[KnownType(typeof(Member))]
public List<IMemberDetail> Member(string idString)
{
var id = int.Parse(idString);
return MemberDAO.Instance().Get(id);
}