Silverlight 3 中的 RIA 服务和关系
我终于设法使用 Silverlight、ADO.NET 实体和 RIA 服务来加载信息,但在获取有关关系的信息时仍然遇到问题。
例如,想象一个产品,该产品有几类属性。我们将它们称为 ProductAreas。
Product 对象有一个名为 ProductAreas 的属性(由于它们的关系),但是当我调用:(
ctx.Load(GetProductsQuery());
其中 ctx 是我的 DomainContext)时,返回的 Product 对象具有 ProductAreas 属性,但它不包含任何元素,这是一个非常严重的问题问题,就我而言。
所以问题是:我如何获得这些关系?
I've finally managed to get a handle on loading information using Silverlight, ADO.NET Entities, and RIA Services, but I'm still having a problem with getting the information about the relationships.
For instance, imagine a product, and that product has several categories of attributes. We'll call them ProductAreas.
The Product object has a property called ProductAreas (as a result of their relationship), but when I call:
ctx.Load(GetProductsQuery());
(Where ctx is my DomainContext), the Product objects returned have the ProductAreas property, but it contains no elements, which is a very serious problem, in my case.
So the question is: How do I get access to these relationships?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定您的
GetProductsQuery()
方法的作用,但您应该能够在查询中使用.Include('ProductAreas')
方法。如果您使用该方法的内容更新您的问题,我将尽力提供更多帮助。I'm not sure what your
GetProductsQuery()
method does, but you should be able use the.Include('ProductAreas')
method in your query. If you update your question with the contents of that method I'll try to help more.从技术上讲,这不是这个系统应该工作的方式,但我想扩展你的答案,同时给予它应有的荣誉,引导我到达我需要的地方。
解决方案是,在 GetProductsQuery() 方法中使用
And而不是
在元数据文件中,转到 Products 类,并在 ProductAreas 属性上方添加 [Include()],使其看起来像:
This isn't technically the way this system is supposed to work, but I wanted to expand on your answer, while at the same time giving it the credit it rightfully deserves for leading me where I needed to be.
The solutions was to, in the GetProductsQuery() method use
instead of
And in the metadata file, go to the Products class and, just above the ProductAreas property add [Include()], so that it looks like: