Override a Linq Datacontext Container
Posted on 2010-09-01
I would like to have a sort of override on a specific class of a linq-2-sql.
Like when fetching data from that class, automatically use a filter.
Something.DataContext db = new Something.DataContext();
var items = db.Items.Where(d=>d.SomeValue > 10);
Which gave me a resultset to items.
The problem is, that I have rows in the items-table that reminds of a "visible = false" or a "validUntilDate < date" that I want to take care of without have to specify it everytime i use that class in the datacontext.
I will remember that there are possible to create a sort of public partial class that inherits the datacontext and add something to it, which will be refered on use from elsewhere. Though, i'm not sure how to format and where to place it.
Some help would be nice!