IComparable not included when serializing in WCF

Posted by djerry on Stack Overflow See other posts from Stack Overflow or by djerry
Published on 2010-05-07T12:15:39Z Indexed on 2010/05/07 12:18 UTC
Read the original article Hit count: 338

Filed under:
|
|
|

Hey guys,

I have a list i'm filling at server side. It's a list of "User", which implements IComparable. Now when WCF is serializing the data, i guess it's not including the CompareTo method. This is my Object class :

[DataContract]
public class User : IComparable
{
    private string e164, cn, h323;
    private int id;
    private DateTime lastActive;

    [DataMember]
    public DateTime LastActive
    {
        get { return lastActive; }
        set { laatstActief = value; }
    }
    [DataMember]
    public int Id
    {
        get { return id; }
        set { id = value; }
    }
    [DataMember]
    public string H323
    {
        get { return h323; }
        set { h323 = value; }
    }
    [DataMember]
    public string Cn
    {
        get { return cn; }
        set { cn = value; }
    }
    [DataMember]
    public string E164
    {
        get { return e164; }
        set { e164 = value; }
    }

    public User()
    {

    }

    public User(string e164, string cn, string h323, DateTime lastActive)
    {
        this.E164 = e164;
        this.Cn = cn;
        this.H323 = h323;
        this.LastActive= lastActive;
    }
    [DataMember]
    public string ToStringExtra
    {
        get
        {
            if (h323 != "/" && h323 != "")
                return h323 + " (" + e164 + ")";
            return e164;
        }
        set { ;}
    }

    public override string ToString()
    {
        if (Cn.Equals("Trunk Line") || Cn.Equals(""))
            if (h323.Equals(""))
                return E164;
            else
                return h323;
        return Cn;
    }

    public int CompareTo(object obj)
    {
        User user = (User)obj;
        return user.LastActive.CompareTo(this.LastActive);
    }
}

Is it possible to get the CompareTo method to reach the client? Putting [DataMember] isn't the solution as i tried it ( i know...).

Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf