You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// DISABLE filter only for class inheriting from BaseDog
153
164
ctx.Filter(MyEnum.EnumValue).Disable();
@@ -163,6 +174,8 @@ var dogs = ctx.Dogs.ToList();
163
174
164
175
```
165
176
177
+
[Try it in EF6](https://dotnetfiddle.net/6aRIYu) | [Try it in EF Core](https://dotnetfiddle.net/JG2gkF)
178
+
166
179
## EF+ Query Filter AsNoFilter
167
180
168
181
You can bypass all filters by using AsNoFilter method in a query if a special scenario doesn't require filtering.
@@ -183,6 +196,8 @@ var list = ctx.Customers.AsNoFilter().ToList();
183
196
184
197
```
185
198
199
+
[Try it in EF6](https://dotnetfiddle.net/xxM1Tl) | [Try it in EF Core](https://dotnetfiddle.net/El05r4)
200
+
186
201
## Real Life Scenarios
187
202
188
203
### Logical Data Partitioning
@@ -207,6 +222,8 @@ var list = ctx.Products.ToList();
207
222
208
223
```
209
224
225
+
[Try it in EF6](https://dotnetfiddle.net/IZhSC0) | [Try it in EF Core](https://dotnetfiddle.net/FALmEw)
226
+
210
227
**Many categories by product**
211
228
212
229
{% include template-example.html %}
@@ -250,6 +267,8 @@ var list = ctx.Invoices.Where(q => q.Where(x => x.CustomerID = myCustomerID)).To
250
267
251
268
```
252
269
270
+
[Try it in EF6](https://dotnetfiddle.net/EyLwE0) | [Try it in EF Core](https://dotnetfiddle.net/uIeV60)
271
+
253
272
### Object State
254
273
255
274
Removing inactive or soft deleted records is probably the most common scenario. A soft delete is often useful when related data cannot be deleted. For example, the customer cannot be deleted because related orders cannot be deleted instead, he becomes inactive.
@@ -268,6 +287,8 @@ var list = ctx.Categories.ToList();
268
287
269
288
```
270
289
290
+
[Try it in EF6](https://dotnetfiddle.net/4vcAQA) | [Try it in EF Core](https://dotnetfiddle.net/1AcyWB)
291
+
271
292
### Security Access
272
293
273
294
Viewing sensible data often requires some permissions. For example, not everyone can see all posts in a forum.
@@ -288,6 +309,8 @@ var list = ctx.Posts.ToList();
288
309
289
310
```
290
311
312
+
[Try it in EF6](https://dotnetfiddle.net/3fsHRV) | [Try it in EF Core](https://dotnetfiddle.net/BknS6x)
313
+
291
314
### Default Ordering
292
315
293
316
Default ordering can be often useful for base table like category. No matter the query, you probably want to show categories by alphabetic order.
@@ -359,6 +382,8 @@ var list = ctx.SetFiltered<Post>().ToList();
359
382
360
383
```
361
384
385
+
[TryitinEF6](https://dotnetfiddle.net/cTEtCX) | [Try it in EF Core](https://dotnetfiddle.net/3203HR)
Copy file name to clipboardExpand all lines: docs2/pages/documentations/query-future.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,7 @@ var states = futureStates.ToList();
30
30
31
31
```
32
32
33
+
[Try it in EF6](https://dotnetfiddle.net/NnXMtb) | [Try it in EF Core](https://dotnetfiddle.net/8gwESn)
33
34
34
35
## EF+ Query Future
35
36
@@ -55,6 +56,8 @@ var states = futureStates.ToList();
55
56
56
57
```
57
58
59
+
[Try it in EF6](https://dotnetfiddle.net/NnXMtb) | [Try it in EF Core](https://dotnetfiddle.net/8gwESn)
60
+
58
61
## EF+ Query FutureValue
59
62
60
63
Query FutureValue delays the execution of the query returning a result.
@@ -77,6 +80,8 @@ int maxPrice = futureMinPrice.Value;
77
80
78
81
```
79
82
83
+
[Try it in EF6](https://dotnetfiddle.net/4K4Fx2) | [Try it in EF Core](https://dotnetfiddle.net/gNCsOR)
84
+
80
85
## EF+ Query FutureValue Deferred
81
86
82
87
Immediate resolution methods like **Count()** and **FirstOrDefault()** cannot use future methods since it executes the query immediately.
@@ -91,6 +96,7 @@ var count = ctx.Customers.Count();
91
96
varcount=ctx.Customers.Future().Count();
92
97
93
98
```
99
+
[Try it in EF6](https://dotnetfiddle.net/lLkiUc) | [Try it in EF Core](https://dotnetfiddle.net/62LQVi)
94
100
95
101
**EF+ Query Deferred** has been created to resolve this issue. The resolution is now deferred instead of being immediate which lets you use FutureValue and get the expected result.
96
102
@@ -101,7 +107,7 @@ var count = ctx.Customers.Future().Count();
101
107
varctx=newEntitiesContext();
102
108
103
109
// GET the first active customer and the number of active customers
0 commit comments