1

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?

Alexander B
  • 93
  • 1
  • 8

2 Answers2

2

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.

Alexander B
  • 93
  • 1
  • 8
1
public class Message
{
    [Key] 
    public string Id { get; set;}
    public string ParentId { get; set; }
    [Include]
    public List<MailInfo> Email { get; set; }
}

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

Try using the attribute. If it is linked in your database it should get these for you.

Rik van den Berg
  • 2,840
  • 1
  • 18
  • 22
  • Thanx, that was the right way. As we can't use single [Include] attribute, we need to add [Association] attribute to bind this two classes so I added [Association("MailInfo","Id","Address")] and everything worked fine – Alexander B Nov 24 '11 at 06:03
  • Actually it compiles. But I can't reach the information - after sending trough RIA, count of EMail is 0. The problem still remains – Alexander B Nov 24 '11 at 07:17
  • If you are using the invoke to get your messages. You might want to implement a callback. As invoke is asynchronous. You maybe forgetting also to put [EnableClientAccess()] attributes above your domain classes Message and MailInfo. Those are the 2 problems I can think of right now. – Rik van den Berg Nov 24 '11 at 08:04