Is it possible to add a default where clause to every SQL statement generated by a Linq-to-SQL class?
I have a custom DataContext with a Customer class. The Customer class has a Deleted attribute, which is what I want to always be NULL whenever I query the table.
So for example, I could write:
List<Customer> customers = db.Customers.ToList<Customer>();
But really get:
List<Customer> customers = db.Customers.Where(o => o.Deleted == null).ToList<Customer>();
I want to maintain the "deleted" data in my DB, but will never need to see it in my .NET code. This sort of default would be handy, so I don't have to remember to add the filter to every query.