Consider the following class:
public class Customer
{
public int Id {get; set;}
public int GroupId {get; set;}
public int Number {get; set;}
public string Name {get; set;}
}
I have a method in the service layer that does:
public Customer Get(Expression<Func<Customer, bool>> where)
{
return customerRepository.Get(where);
}
The calling code is:
var customer = customerService.Get(x => x.Number == number);
In the above method, the user searches a customer based on a property (excluding GroupId
because this is hidden in the ViewModel). However, a user is always assigned to a group, and therefore, he is only allowed to search for customers within his group. So the GroupId
must be added dynamically.
How can I add the GroupId
to the where
expression in the method above. The GroupId
may or may not be already available in the expression.