File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
docs2/pages/ef-docs/documentations/query-db-set-filter/options Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ Permalink : ef6-query-db-set-filter-by-inheritance-interface
3+ ---
4+
5+ # EF+ Query Filter By Inheritance/Interface
6+
7+ Filter can be enabled and disabled by class inheritance and interface.
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 inheritance
16+ ctx .DbSetFilter <BaseDog >(q => q .Where (x => ! x .IsDangerous ));
17+
18+ // CREATE filter by interface
19+ ctx .DbSetFilter <IAnimal >(q => q .Where (x => x .IsDomestic ));
20+
21+ // SELECT * FROM Cat WHERE IsDomestic = 1
22+ var cats = ctx .Cats .ToList ();
23+
24+ // SELECT * FROM Dog WHERE IsDomestic = 1 AND IsDangerous = 0
25+ var dogs = ctx .Dogs .ToList ();
26+
27+ ```
28+ [ Try it] ( https://dotnetfiddle.net/flFnBf )
You can’t perform that action at this time.
0 commit comments