Search code examples
c#silverlightwcf-ria-services

sending complex structures via WCF RIA services


I'm having a trouble with sending complex structure. I have two classes. I send through ria services a list of messages, every message contains a list of classes describing people involved in conversation - MailInfo

public class Message
{
    [Key] 
    public string Id { get; set;}
    public string ParentId { get; set; }
    public List<MailInfo> Email { get; set; }
}

public class MailInfo
{
    [Key]
    public string Address { get; set; }
}

To send a List of Message I use

[Query]
public IQueryable<Message> GetMessage() {return null;}
[Query]
public IQueryable<MailInfo> GetMailInfo() { return null; }

and eventually

[Invoke]
public List<Message> SomeMethod ()
{ return listofMessages; }

But I cannot have access to Email field of Message. Can I do something? Or just such complex structures are not supported in silverlight yet?


Solution

  • Actually I found out that you cannot send such class object properly. The point is that RIA services disable a setter for non-POCO objects of the class you are going to send. You can see it in generated code .Web.g.cs. The only beautiful solution I found out - is to send List EMail as a serialized string. So after that all of your fields in entity would be POCO and you finally get the object.