File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
docs2/pages/ef-docs/documentations/query-db-set-filter/options Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ Permalink : ef6-query-db-set-filter-by-enable-disable
3+ ---
4+
5+ # EF+ Query Filter Enable/Disable
6+
7+ Filters are very flexible, you can enable and disable them at any time and only for a specific inheritance or interface if desired.
8+
9+ {% include template-example.html %}
10+ ``` csharp
11+
12+ // using Z.EntityFramework.Plus; // Don't forget to include this.
13+ var ctx = new EntitiesContext ();
14+
15+ // CREATE filter by interface
16+ ctx .DbSetFilter <IAnimal >(MyEnum .EnumValue , q => q .Where (x => x .IsDomestic ))
17+
18+ // DISABLE filter
19+ ctx .DbSetFilter (MyEnum .EnumValue ).Disable ();
20+
21+ // SELECT * FROM Dog
22+ var dogs = ctx .Dogs .ToList ();
23+
24+ // ENABLE filter
25+ ctx .DbSetFilter (MyEnum .EnumValue ).Enable ();
26+
27+ // SELECT * FROM Dog WHERE IsDomestic = true
28+ var dogs = ctx .Dogs .ToList ();
29+
30+ ```
31+ [ Try it] ( https://dotnetfiddle.net/girbYB )
You can’t perform that action at this time.
0 commit comments