Skip to content

Commit 7a3e20c

Browse files
author
fabien.menager
committed
Update readme with notes about new features in v6
1 parent 2d195f9 commit 7a3e20c

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ ORDER BY (COALESCE("u"."FirstName", '') || ' ') || COALESCE("u"."LastName", '')
163163

164164
#### Can I use block-bodied members instead of expression-bodied members?
165165

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:
167170

168171
```csharp
169172
// Expression-bodied (still supported)
@@ -195,7 +198,10 @@ The generator will also detect and report side effects (assignments, method call
195198

196199
#### Can I use `[Projectable]` on a constructor?
197200

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.
199205

200206
**Requirements:**
201207
- 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
312318

313319
Multiple `[Projectable]` constructors (overloads) per class are fully supported.
314320

315-
> **Note:** If the delegated constructor's source is not available in the current compilation, the generator reports **EFP0009** and skips the projection.
321+
> [!NOTE]
322+
> If the delegated constructor's source is not available in the current compilation, the generator reports **EFP0009** and skips the projection.
316323

317324
#### Can I redirect the expression body to a different member with `UseMemberBody`?
318325

@@ -343,7 +350,8 @@ public class Entity
343350

344351
The generated expression is `(@this) => @this.Id * 2`, so `Computed` projects as `Id * 2` in SQL even though the arrow body says `Id`.
345352

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.
347355
348356
##### Using an `Expression<Func<...>>` property as the body
349357

@@ -430,7 +438,10 @@ The generated expression is `(Foo a, Foo b) => a.Name == b.Name` — the same la
430438

431439
#### Can I use pattern matching in projectable members?
432440

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.
434445

435446
**Switch expressions** with the following arm patterns are supported:
436447

@@ -503,7 +514,11 @@ public static ItemData ToData(this Item item) =>
503514
Unsupported patterns (e.g. positional/deconstruct patterns, variable designations outside switch arms) are reported as **EFP0007**.
504515

505516
#### 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 (like getting a display name from a `[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 (like getting a display name from a `[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.
507522

508523
```csharp
509524
public enum OrderStatus

0 commit comments

Comments
 (0)