Because of performance tuning I would like to return only necessary properties. Is there a possibility/workaround? Pseudo / sample code to understand:
[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; }
}
and the service:
[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);
}