WCF Compare objects on client
Well i have a WCF service and it has two methods one that gives a singel object and one that gives a list of objects..
the object returned from method one is part of the list from method two.
Im using wpf and binding a combo box to the two the results..
but the problem is that the combo box dosent know how to compare the objects as WCF did not generate this for me.. is there some way to fix this??
Edit: Sample
interface IServer
{
[OperationContract()]
开发者_运维问答 Entity GetById(Guid id);
[OperationContract()]
List<Entity> GetAll();
}
[DataContract()]
class Entity
{
[OperationContract()]
public Guid ID {get;set;}
[OperationContract()]
public string Name{get;set;}
}
How do i make sure that when Entity objects are compared the ID field is used for this compare?
Since the datacontract autogenerated on the client is a partial class, you can extend it by creating another partial class with same name/namespace and derive it form IComparable, then implement IComparable as needed.
精彩评论