WAQS: Server filters

7 reasons to use WAQS

WAQS documentation

 

We saw that, using WAQS, we can querying directly from the client.

But, when we do this, we sometimes want to be able to filter the result in the server in order to not expose everything to everybody. So it’s important to be able to add some filters in the server on the data sent to the client.

One of the good things with code generation is the ability to use partial methods which often is a very good, flexible and easy way to define configuration IMHO and WAQS uses it a lot.

For example, if you only want to return the orders of the connected customer, you just have to extend NorthwindEntitiesFilters class:

partial class NorthwindEntitiesFilters
{
    partial void ApplyOrdersServerWhere(ref Expression<Func<Order, bool>> filterExpression)
    {
        string customerId = GetCurrentCustomerId();
        filterExpression = o => o.CustomerId == customerId;
    } }


Of course, this filter will be included in LINQ To Entities query anytime we use the Order class in LINQ To WAQS query and therefore will be included in the SQL query.



 



Note that, for a better understanding of the next posts, we won’t keep this filter.

This entry was posted in 16868, 17895. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>