3

I am having trouble getting related entities to be loaded on the client using RIA Services and EF 4.1 with Silverlight.

I'm currently using the Include() method on my DbDomainService with an Expression parameter and am finding that when stepping through my service the related entities are loaded just fine. However, when the Queryable results are returned to the client NO related entities are loaded - they are null. All of my entities are marked with the [DataMember] attribute so I have assumed that it isn't a serialization issue. Moreover, my DbDomainService query method is marked with the [Query] attribute.

I was wondering if there is anything specific that has to be set up on the client when using RIA Services with EF 4.1 code first? I must be missing something, but I'm not sure what.

Any help would be appreciated.

Thanks,

sfx

1 Answer 1

5

While you may have used the .Include() in your service call, you also have to add the [Include] attribute in the metadata class that is also created.

The .Include() statement tells EF to generate the SQL necessary to retrieve the data, while the Include attribute tells WCF RIA Services to make sure the Entity Class is also created on the client.

Once the data arrives at the client, it needs to know what type of structure to put it in as well.

HTH

3
  • Thanks, that worked! Do you know if there is a way to achieve the same thing using the fluent API? I prefer not to use annotations on my domain model and the metadata nested class approach seems cumbersome.
    – Xam
    Commented Sep 24, 2011 at 23:32
  • Not that I am aware of using WCF RIA Services. You could write your own service, but that is a lot more work including change tracking.
    – codeputer
    Commented Sep 26, 2011 at 21:56
  • That worked for me! I thought the Include attribute only tells RIA it should be generated in client, so since it's exposed anywhere I thought no need to decorate with att. Thank you! Commented Jan 25, 2012 at 1:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.