Jonathan
Jonathan

Reputation: 1296

WCF DataContract with collection property

WHY this does not work for the ContactData[] array property !? the received array is always empty!!!

WCF can serialize ContactData whithout any problem, but not a simple array of ContactData !?!? this is crazy o_O

What is the simplest and fastest way to send correctly this collection of ContactData through a wcf call ??

[DataContract]
public class MessageData
{       
    [DataMember]
    public ContactData From { get; set; }

    [DataMember]
    public ContactData[] To { get; set; }

    [DataMember]
    public string MessageText { get; set; }
}

[DataContract]
public class ContactData
{
    [DataMember]
    public string Name { get; set; }

    [DataMember]
    public string Address { get; set; }
}

Upvotes: 0

Views: 1355

Answers (2)

user758453
user758453

Reputation: 46

try

public List<'ContactData> To { get; set; }

remove ' in <'

Upvotes: 0

Jonathan
Jonathan

Reputation: 1296

It turned out to be my service reference that was not up to date, i deleted and recreated the service reference and it just worked fine, sorry for my stupidity...

I misunderstood something I had read about serialization of collections and thought there was something different to do here.

Upvotes: 1

Related Questions