Trex
Trex

Reputation: 145

Silverlight4: Loading 2nd level data from RIA Services domain service in many-to-many scenario

I have the following database structure:

Children --> Gifts <-- Possible_gifts, where the arrow denotes 1-to-many relationship, i.e. "Each child can have many gifts and each one of those gifts is one of the Possible_gifts." (forming the classical many-to-many relationship). Possible_gifts table includes (among other things) the names of the gifts, the Gifts table only has the ID of the Possible_gift, the ID of the child and some other necessary data (like date, etc.)

Now in the Silverlight client I need to get not only the Child and Gift data from the domain service, but also the Possible_gifts table data (mainly the name of each Gift that is associated with the selected Child). I tried:

return this.ObjectContext.Children.Include("Gifts").Include("Gifts.Possible_gifts") as suggested somewhere else, but it doesn't work.

Does anybody have an idea how to solve this?

Thanks.

Upvotes: 1

Views: 240

Answers (1)

Trex
Trex

Reputation: 145

Discovered where the problem was. I was missing an [Include] attribute in the metadata class of the domain service. It turns out that having the above mentioned code in the domain service alone doesn't do the trick!

Upvotes: 2

Related Questions