I just checked new futures in Entity Framework Core 2.0. It has a really nice feature called "String interpolation in raw SQL methods" which is described here .
It says that this code:
var city = "Redmond";
using (var context = CreateContext())
{
context.Customers.FromSql($@"
SELECT *
FROM Customers
WHERE City = {city}");
}
creates this request:
SELECT *
FROM Customers
WHERE City = @p0
This is really weird for me! How a method is FromSqlwritten as it is, and introduces a type string.
How does he understand that this is an interpolated string, and then create a parameter for it @p0? How can I write a method, for example FromSql, that knows how its string parameters are created?
source
share