Skip to content

Commit 1d1a23e

Browse files
CopilotAndriySvyryd
andcommitted
Modernize code sample with primary constructor and expression-bodied methods
Co-authored-by: AndriySvyryd <[email protected]>
1 parent 94791e4 commit 1d1a23e

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

entity-framework/core/what-is-new/ef-core-10.0/breaking-changes.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,24 +193,15 @@ await context.Blogs.ExecuteUpdateAsync(s =>
193193
Previously, when using value converters with compiled models (using `dotnet ef dbcontext optimize`), EF would reference the converter type and everything worked correctly.
194194

195195
```c#
196-
public sealed class BooleanToCharConverter : ValueConverter<bool, char>
196+
public sealed class BooleanToCharConverter() : ValueConverter<bool, char>(v => ConvertToChar(v), v => ConvertToBoolean(v))
197197
{
198198
public static readonly BooleanToCharConverter Default = new();
199199

200-
public BooleanToCharConverter()
201-
: base(v => ConvertToChar(v), v => ConvertToBoolean(v))
202-
{
203-
}
204-
205200
private static char ConvertToChar(bool value) // Private method
206-
{
207-
return value ? 'Y' : 'N';
208-
}
201+
=> value ? 'Y' : 'N';
209202

210203
private static bool ConvertToBoolean(char value) // Private method
211-
{
212-
return value == 'Y';
213-
}
204+
=> value == 'Y';
214205
}
215206
```
216207

0 commit comments

Comments
 (0)