Derik Whittaker



Help RIA Services is NOT returning my entire object graph

***** NOTE: I (we) may be doing this 100% wrong so if I am please let me know a better way *****

Ok, this is a complete NEWBIE post by me, but hey I am just learning WCF RIA Services. If you are like me and you are learning you may run into the scenario I have a few times where data is present during inspection on the server side but NOT on the client side. 

If you run into this scenario there are 2 things you should check;

  1. You have explicitly included our child objects in your EF query
  2. You have provided the correct ‘Include’ property on your child entity via the MetadataTypeAttribute

How to ensure your EF queries have included your child objects?

// The key to the EF logic below is the .Include statement
public IQueryable GetLinkCollection(int clientID)
	var result = ObjectContext.kLinkCollections
                .Where(m => m.ClientID == clientID);

	return result;

How to ensure your RIA services have your child objects exposed?

// The trick to this code below is the [Include] attribute on your child objects
public partial class LinkCollection
	internal sealed class LinkCollectionMetadata

            // Metadata classes are not meant to be instantiated.
            private LinkCollectionMetadata()

            public EntityCollection<QuickLink> QuickLinks { get; set; }

            public ClientQuickLinkCollectionType LinkCollectionType { get; set; }


Like I said above it is possible that I am doing something completely wrong, but ensuring the above 2 items are setup correctly has solved my problem. I should also note that the class tree which is being returned back from the RIA call was created AFTER the initial setup wizard was run and we cannot find anyway to re-run the wizard without blowing away the original code and having it recreated.

Hope this helps the next newbie Smile

Till next time,

Posted 06-23-2011 11:36 AM by Derik Whittaker



Akhil Deshpande wrote re: Help RIA Services is NOT returning my entire object graph
on 06-26-2011 9:53 AM

This is the correct way to do it.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)