How to apply global filter on Linq Connect?
Posted: Mon 12 Aug 2013 12:39
I have many tables each with a "DeletedStatus" flag that is our soft delete. We don't want to ever delete anything from the database but when a user deletes a record it should never be accessed by the application. I could put a filter in every single query I write but that seems a little redundant. Is there a way to apply a filter on the context creation? I looked at the "AssociatesWith" and "LoadWith" functionality but when I do this in the ".Designer.cs" file I get a "Subquery must be a sequence" or "Expression with member access are only allowed" errors.
What are my options for applying a specific filter on these tables for all queries?
Code: Select all
partial void OnCreated(){
DataLoadOptions dlo = new DataLoadOptions();
dlo.AssociateWith<Agency>(x => x.DeletedStatus != true);
this.LoadOptions = dlo;
}