views:

36

answers:

0

I'm working on a project that groups data by a "customer id". When the user logs in, they're limited to that customer and that customer only.

I'm working with SubSonic3, and what I've got looks something like this:

public IEnumerable<Models.Foo> FindFoo(int userID, string searchText, int pageIndex, int pageSize)
{
    return from item in Foo.GetPaged(pageIndex, pageSize)
           where (item.Name.Contains(searchText) ||   
                  item.Description.Contains(searchText)) &&
                  item.CustomerID == CurrentCustomerID()
                  select new Models.Foo(item);
}

What I'd like to do is abstract away the item.CustomerID line, because that's going to happen for every query, without fail, so it would be simpler (and more secure) to do it in one place and guarantee it'll happen everywhere.

So, my question is: can this be done, and if so, how?