How to use expand with reflection provider and custom query interceptor RRS feed

  • Question

  • Hello,

    I am exposing my domain object model through assorted WCF Data Services.  The domain model lives off in a storage medium (i.e. database, xml files, etc...).  I am currently using a reflection provider with a custom IQueryable implementation that intercepts the expression generated by the WCF Data Service and translates it to something that I can execute over my storage medium.  This works very well.  The only snag I have hit so far is with the expand feature.  This does not seem to equate to anything in the expression tree than I can intercept and apply.

    When using a custom queryable implementation with a reflection provider is there any way to access the expand specifications?  The only workaround I have right now is to load the related domain objects and let the data service apply the expand criteria post query, but it would be a little more efficient if I could filter this out from the query altogether.


    Friday, April 20, 2012 3:07 PM


  • Hi,

    Reflection provider has an assumption that navigation properties can "lazy" load on demand their content. So unless there's something else in the query which forces it, it doesn't express the expansions in the expression tree.

    So there are two options I can thin of:

    - Switch to custom provider. Since you already have IQueryable which is the most difficult part anyway, implementing the custom provider around it shouldn't be that hard. The most of the metadata provider, which depends on what features you use and where. The expression trees for custom providers always contain full description of all expansions (there are no assumptions made).

    - Force usage of more descriptive expressions even with reflection provider. One way to do this would be to use server driven paging. For a navigation property which points to entity set which has a server driven paging set on it, the expression tree will contain the description of the expansion plus the server driven paging part. The upside is that you might want server driven paging anyway for performance/security reasons. The downside is that it complicates the expression trees quite a bit.

    In any case, this blog post describes how expansions look in the expression trees: http://blogs.msdn.com/b/vitek/archive/2010/07/15/data-services-expressions-part-9-expansions.aspx


    Vitek Karas [MSFT]

    • Marked as answer by BotHead Friday, April 20, 2012 7:58 PM
    Friday, April 20, 2012 3:53 PM