How to apply global filter on Linq Connect?

How to apply global filter on Linq Connect?

Postby chansohn » 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.
Code: Select all
partial void OnCreated(){
DataLoadOptions dlo = new DataLoadOptions();
dlo.AssociateWith<Agency>(x => x.DeletedStatus != true);
this.LoadOptions = dlo;

What are my options for applying a specific filter on these tables for all queries?
Posts: 1
Joined: Mon 12 Aug 2013 12:26

Re: How to apply global filter on Linq Connect?

Postby MariiaI » Tue 13 Aug 2013 09:01

Could you please describe the scenario you want to implement in more details:
- the DBMS you are working with;
- the version of LinqConnect;
- the definitions of the entity classes and the corresponding database tables;
- what exactly actions should be done (the steps we should perform to implement your scenario), etc.

If possible, please send us a small test project so that we are able to investigate your question in more details and find the solution for you.
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Return to LinqConnect (LINQ to SQL support)