开发者

RIA Services and Relationships in Silverlight 3

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?


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.


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

return this.ObjectContext.Products.Include("ProductAreas");

instead of

return this.ObjectContext.Products;

And in the metadata file, go to the Products class and, just above the ProductAreas property add [Include()], so that it looks like:

[Include()]
public EntityCollection<ProductAreas> ProductAreas;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜