efcore.pg
efcore.pg copied to clipboard
Switch to C# 11 raw string literals for SQL baselines
@dotnet/efteam, I needed a break from real work so I changed al SQL baselines to use the new raw string literals... Take a look, I think it looks great!
AssertSql(
"""
DELETE FROM "Animals" AS a
WHERE a."Discriminator" = 'Kiwi' AND a."CountryId" = 1 AND a."Name" = 'Great spotted kiwi'
""");
Note that for PostgreSQL and Sqlite it's even more useful, since double-quotes no longer need to be escaped!
Let's see what people think, I can do the same for EF (https://github.com/dotnet/efcore/issues/28260) (in MQ...)
Part of #2470
Regular expressions
This doesn't work for multi-command executions, need to improve.
Pattern:
(?s)AssertSql\(\n\s*@"(.*?)"\);\n
Replace:
AssertSql\("""
$1
"""\);\n