WCF Data Services Feature Suggestions

Add more extensibility points to give query interceptors more control over what they're intercepting

Not sure if there is already some other mechanism in place for this... ...but it would be neat if it was possible to intercept whatever the dataservice framework adds to IQueryables exposed by data services before enumerating them. If a filter, sort, paging or something else is added server side or as a result of a user request I may want to apply additional rules and/or change how this is added to the query. Especially on IQueryables with large underlying sets of data and/or a complex base query it can be important to be able to control filters and sorting to avoid having users kill the underlying database...

Maybe something along the lines of:

[QueryFilterInterceptorEx("Orders")]
public IQueryable<Order> OnQueryFilterOrders(IQueryable<Order> baseQuery, Expression<Func<Order, bool>> filterExpression)
{
if (expression.FindMemberExpression("SomeMemberName"))
{
return baseQuery.Where(filterExpression).Where(f => f.SomeAdditionalFilter == 123);
}
else
{
return baseQuery.Where(filterExpression);
}
}

[QuerySortInterceptorEx("Orders")]
public IQueryable<Order> OnQuerySortOrders(IQueryable<Order> baseQuery, Expression<Func<Order, TKey>> sortExpression)
{
if (sortExpression.Body is MemberExpression
&& ((MemberExpression)sortExpression.Body).Member.Name == "SomeMember")
{
return (IQueryable<Order>)baseQuery.OrderBy(sortExpression);
}
else
{
return (IQueryable<Order>)baseQuery.AsEnumerable().OrderBy(sortExpression);
}
}

(also see this related forum thread: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/d853d6f2-c1f1-4acc-9657-cc575dec2d03 )

97 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Mike FlaskoAdminMike Flasko (Lead Program Manager, DataFx) shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • cibraxcibrax commented  ·   ·  Flag as inappropriate

        I would be great to have a way to inject interceptors dynamically, and not something static in the data service.

      Feedback and Knowledge Base