Operation instead of query interceptor (WCF Data Services)

折月煮酒 提交于 2019-12-05 13:29:59

I played around a little more with this and one of the issues is navigation properties won't be filtered. Let's say you have an entity called SalesPeople that has a link into IEnumberable of Customers

If you do

[QueryInterceptor("Customers")] // only show active customers
public Expression<Func<Customers, bool>> ActiveCustomers()
{
    return cust => cust.IsDeleted == false;
}

when you query your OData feed like WCFDataService.svc/SalesPeople?$expand=Customers the results set for Customers will still have the filter applied.

But this

[WebGet]
public IQueryable<Customers> Customers()
{                    
    return this.CurrentDataSource.Customers.Where(x=>x.IsDeleted==false);
}

When running OData query like WCFDataService.svc/Customers you will have the filtered list on active customers, but when running this WCFDataService.svc/SalesPeople?$expand=Customers the results set for the Customers will include deleted customers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!