通过 RIA 服务发送包含的对象

发布于 2024-08-04 10:40:19 字数 259 浏览 4 评论 0原文

我有这样的类:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眸中客 2024-08-11 10:40:19

您需要在引用的类上使用 [Include] 属性来指示您也希望这些类被序列化:

public class Monkey 
{
   [Key]   
   int number;
   String mystring;

   [Include]
   OtherObject anotherobject;
}

这也可以在代码中完成:

public IQueryable<Monkey> GetMonkeys()
{            
   var Monkey = this.Context.Monkey.Include("Monkey.OtherObject");
   return Monkey;
} 

一些引用:

You need to use the [Include] attribute on referenced classes to indicate that you want those classes serialized as well:

public class Monkey 
{
   [Key]   
   int number;
   String mystring;

   [Include]
   OtherObject anotherobject;
}

This can also be done in code:

public IQueryable<Monkey> GetMonkeys()
{            
   var Monkey = this.Context.Monkey.Include("Monkey.OtherObject");
   return Monkey;
} 

Some references:

塔塔猫 2024-08-11 10:40:19

您需要在对象上方执行[包含]和[关联],并且关联参数需要是其他对象[关键]

此外,您可以从服务器发送到客户端,但不能从客户端发送到服务器,这就是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

请你别敷衍 2024-08-11 10:40:19

我认为问题在于您必须使 OtherObject 可序列化。另外两个变量是原语,因此它们已经是可序列化的。

例如:

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

您必须添加 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:

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文