通过 RIA 服务发送包含的对象
我有这样的类:
public class object {
[Key]
int number;
String mystring;
OtherObject anotherobject;
}
当我通过 RIA 发送这个时,我的 silverlight 应用程序可以看到 object.number 和 object.mystring,但看不到 object.anotherobject! 我应该怎么办??请帮我。
I have class like this:
public class object {
[Key]
int number;
String mystring;
OtherObject anotherobject;
}
WHen i sent this over RIA my silverlight application can see object.number and object.mystring, but not object.anotherobject!!!
What should i do?? Please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要在引用的类上使用 [Include] 属性来指示您也希望这些类被序列化:
这也可以在代码中完成:
一些引用:
http://www.silverlightshow.net/items/Creating- applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx
http://博客。 msdn.com/brada/archive/2009/07/22/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-part-6-poco-and-authentication- provider.aspx
You need to use the [Include] attribute on referenced classes to indicate that you want those classes serialized as well:
This can also be done in code:
Some references:
http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx
http://blogs.msdn.com/brada/archive/2009/07/22/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-part-6-poco-and-authentication-provider.aspx
您需要在对象上方执行[包含]和[关联],并且关联参数需要是其他对象[关键]
此外,您可以从服务器发送到客户端,但不能从客户端发送到服务器,这就是RIA的工作原理,因为它有点糟糕
You need to do [Include] and [Association] above the object and the association parameters need to be the other objects [Key]
Also you can send from Server to Client but not CLient to server thats just how RIA works cause it kind of sucks
我认为问题在于您必须使
OtherObject
可序列化。另外两个变量是原语,因此它们已经是可序列化的。例如:
您必须添加 System.RunTime.Serialization 作为参考。
您可能必须对代码中包含的类执行相同的操作。
I believe the issue is that you have to make the
OtherObject
serializable. The other two variables are primitives and therefore they are already serializable.For Example:
You will have to add
System.RunTime.Serialization
as a reference.It could be that you will have to do the same to the class you included in your code.