Is it possible to make a custom QueryInterceptor in a WCF Data Service on all entites instead of only one? This is a standard QueryInterceptor:
[QueryInterceptor("Products")]
public Expression<Func<Product, bool>> OnQueryProducts()
{
var user = HttpContext.Current.User;
if (user.IsInRole("Administrator"))
return (Product p) => true;
else
return (Product p) => false;
}
I like to do something like this:
[QueryInterceptor("*")]
public Expression<Func<Object, bool>> OnQueryProducts()
{
var user = HttpContext.Current.User;
if (user.IsInRole("Administrator"))
return (Object p) => true;
else
return (Object p) => false;
}
Is there any way or do I have to integrate one inceptor for all of my entities?
Unfortunately you can't use a wild card with the QueryInterceptor however you can achieve the same result as in your example by overriding the OnStartProcessingRequest method of the DataService and checking the role of the user there.