2 ms·
This is already a thing: https://learn.microsoft.com/en-us/ef/core/querying/sql-queries https://learn.microsoft.com/en-us/ef/core/querying/sql-queri... although
by neonsunset 2y ago
This is already a thing: https://learn.microsoft.com/en-us/ef/core/querying/sql-queries https://learn.microsoft.com/en-us/ef/core/querying/sql-queri... although it uses an older API - https://learn.microsoft.com/en-us/dotnet/api/system.formattablestring https://learn.microsoft.com/en-us/dotnet/api/system.formatta...
Interpolated string handlers are a newer API made primarily with customization and efficiency of interpolation in mind. They are more complicated to implement and use but enable zero-cost and/or zero-allocation use cases and performing custom behavior on appending literals or data. They are also used to implement the default string interpolation handler and a few auxiliary ones like Append handler for a string builder which writes directly into it, bypassing intermediate string construction.
It's quite a mouthful to say though but very useful for advanced scenarios. Haven't seen any other language provide anything comparable.
See also: https://devblogs.microsoft.com/dotnet/string-interpolation-in-c-10-and-net-6/ https://devblogs.microsoft.com/dotnet/string-interpolation-i...