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
Copy file name to clipboardExpand all lines: README.md
+21-6Lines changed: 21 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,7 +163,10 @@ ORDER BY (COALESCE("u"."FirstName", '') || ' ') || COALESCE("u"."LastName", '')
163
163
164
164
#### Can I use block-bodied members instead of expression-bodied members?
165
165
166
-
Yes! As of version 6.x, you can now use traditional block-bodied members with `[Projectable]`. This makes code more readable when dealing with complex conditional logic:
166
+
> [!NOTE]
167
+
> This feature is available starting from version 6.x and is considered experimental.
168
+
169
+
Yes! you can now use traditional block-bodied members with `[Projectable]`. This makes code more readable when dealing with complex conditional logic:
167
170
168
171
```csharp
169
172
// Expression-bodied (still supported)
@@ -195,7 +198,10 @@ The generator will also detect and report side effects (assignments, method call
195
198
196
199
#### Can I use `[Projectable]` on a constructor?
197
200
198
-
Yes! As of version 6.x, constructors can now be marked with `[Projectable]`. The generator will produce a member-init expression (`new T() { Prop = value, … }`) that EF Core can translate to a SQL projection.
201
+
> [!NOTE]
202
+
> This feature is available starting from version 6.x.
203
+
204
+
Yes! constructors can now be marked with `[Projectable]`. The generator will produce a member-init expression (`new T() { Prop = value, … }`) that EF Core can translate to a SQL projection.
199
205
200
206
**Requirements:**
201
207
- The class must expose an accessible **parameterless constructor** (public, internal, or protected-internal), because the generated code relies on `new T() { … }` syntax.
@@ -312,7 +318,8 @@ The generated expression inlines both the base constructor and the derived const
>**Note:**Ifthedelegatedconstructor's source is not available in the current compilation, the generator reports **EFP0009** and skips the projection.
321
+
> [!NOTE]
322
+
>Ifthedelegatedconstructor's source is not available in the current compilation, the generator reports **EFP0009** and skips the projection.
316
323
317
324
#### Can I redirect the expression body to a different member with `UseMemberBody`?
318
325
@@ -343,7 +350,8 @@ public class Entity
343
350
344
351
The generated expression is `(@this) => @this.Id * 2`, so `Computed` projects as `Id * 2` in SQL even though the arrow body says `Id`.
345
352
346
-
> **Note:** When delegating to a regular method or property body the target member must be declared in the **same source file** as the `[Projectable]` member so the generator can read its body.
353
+
> [!NOTE]
354
+
> When delegating to a regular method or property body the target member must be declared in the **same source file** as the `[Projectable]` member so the generator can read its body.
347
355
348
356
##### Using an `Expression<Func<...>>` property as the body
349
357
@@ -430,7 +438,10 @@ The generated expression is `(Foo a, Foo b) => a.Name == b.Name` — the same la
430
438
431
439
#### Can I use pattern matching in projectable members?
432
440
433
-
Yes! As of version 6.x, the generator supports a rich set of C# pattern-matching constructs and rewrites them into expression-tree-compatible ternary/binary expressions that EF Core can translate to SQL CASE expressions.
441
+
> [!NOTE]
442
+
> This feature is available starting from version 6.x.
443
+
444
+
Yes! the generator supports a rich set of C# pattern-matching constructs and rewrites them into expression-tree-compatible ternary/binary expressions that EF Core can translate to SQL CASE expressions.
434
445
435
446
**Switch expressions** with the following arm patterns are supported:
Unsupportedpatterns (e.g. positional/deconstructpatterns, variabledesignationsoutsideswitch arms) are reported as **EFP0007**.
504
515
505
516
#### How do I expand enum extension methods?
506
-
As of version 6.x, when you have an enum property and want to call an extension method on it (likegettingadisplaynamefroma `[Display]` attribute), you can use the `ExpandEnumMethods` property on the `[Projectable]` attribute. This will expand the enum method call into a chain of ternary expressions for each enum value, allowing EF Core to translate it to SQL CASE expressions.
517
+
518
+
> [!NOTE]
519
+
> This feature is available starting from version 6.x.
520
+
521
+
When you have an enum property and want to call an extension method on it (likegettingadisplaynamefroma `[Display]` attribute), you can use the `ExpandEnumMethods` property on the `[Projectable]` attribute. This will expand the enum method call into a chain of ternary expressions for each enum value, allowing EF Core to translate it to SQL CASE expressions.
0 commit comments