Operation instead of request interceptor (WCF data services)

I read about request interceptors . I was disappointed because it was more of a filter than a sniffer. In other words, you can turn records on or off. For example, you cannot change records.

If I want to create an intercept request for my object Users, I could do something like:

[QueryInterceptor("Users")] // apply to table users
public Expression<Func<User, bool>> UsersOnRead()
{
    return cust => cust.IsDeleted == false;
}

What to do if I create an operation instead: NOTE IT IS VERY IMPORTANT TO HAVE OPERATIONS ONLY AS THE COMPANY NAME SOMETIMES DOES NOT WORK

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

Placing this method instead of request interceptor makes my service the same. Plus I have more energy! Does this approach use a better solution?

+4
1

, - . , SalesPeople, IEnumberable of Customers

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

OData, WCFDataService.svc/SalesPeople? $expand = , - .

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

OData, WCFDataService.svc/Customers, , WCFDataService.svc/SalesPeople? $expand = , , , .

+5

Source: https://habr.com/ru/post/1537403/


All Articles