I often need to call scalar functions that are defined on a SQL Server from my web applications (ASP.NET Core / EF Core). Since these functions are just simple helper functions
Unfortunately it seems this feature has been left aside: https://github.com/aspnet/EntityFrameworkCore/issues/9810
An option is to wrap the functions calls in a static class using a small table which is never empty:
public static class DbFunctions
{
public static decimal MyFunctionABC(int param1, int param2)
{
using (var db = new MyDbContext())
{
return db.table.Take(1).Select(t => MyDbContext.MyFunctionABC(x, y)).Single();
}
}
}
Then you can call DbFunctions.MyFunctionABC(x,y);