views:

209

answers:

1

We're using query interceptors in ADO.NET Data Services in our application to filter the result set for each entity based on the data that a user has access to. However I'm getting the following exception thrown from one of our query interceptors:

Internal .NET Framework Data Provider error 1004, 0, Related Entities cannot be specified for Entity constructors that are not part of the Query Mapping View for an Entity Set..

Does anyone know when/why this exception is thrown?

To add some context to this post I'm using the following filter criteria in my URL:

$filter=(OnlineItems/Products/ProductId eq 856)

where the query interceptor is:

        [QueryInterceptor("OnlineItems")]
        public Expression<Func<OnlineItems, bool>> QueryOnlineItems()
        {
            return item => (item.Products.Any(p => p.Price > 10));
        }

As a stab in the dark I would imagine it would be the combination of filtering on Products as well as expanding on Products but I'm not sure how this causes the whole thing to fall over.

+1  A: 

For some reason this works:

[QueryInterceptor("OnlineItems")]
public Expression<Func<OnlineItems, bool>> QueryOnlineItems()
{
    return item => (item.Products.Count(p => p.Price > 10) > 0);
}

Does anyone know why this would work and not the "Any" case?

James_2195

related questions