A service that returns paged Products with optional filtering
I would suggest you to move the pagination settings to your SearchModel

Then you can have an utility/extension method or whatever you whish with this signature

public IQueryable&lt;Product&gt; ApplyFilter(IQueryable&lt;Product&gt; productQuery, SearchModel model)


and you write there ll the filtering business, so you can re use it in more methods and simplify the readability of your main method.

Finally, I would not recommend to rewrite your if statements like this

if (search.CategoryId != 0)
{
    products = products.Where(p =&gt; p.CategoryId == search.CategoryId);
}