I'm using Postgresql with EF Core 3.1 on my ASP.NET project
I want to generate a sql fragment like this:
EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE f."MyDateTimeField")"
So, I have writed this code on OnModelCreating method of the DbContext:
modelBuilder
.HasDbFunction(typeof(MyDbFunctions).GetMethod(
nameof(MyDbFunctions.ExtractEpochFromTimestampWithTimezone)))
.HasTranslation(args
=> SqlFunctionExpression.Create(
"EXTRACT",
new []
{
new SqlFragmentExpression(
$"EPOCH FROM TIMESTAMP WITH TIME ZONE"),
args.First()
}, typeof(double), null));
But the generated SQL fragment was:
EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE, f."MyDateTimeField")
Note that SQL has one "," after word "ZONE".
How can I fix my code to generate the SQL fragment without this ","?