EFCore 2.0引用标量函数

参考文档:https://www.cnblogs.com/CreateMyself/p/8485697.html

1、添加nuget包:EntityFramework.Functions,在上下文类MainDbContext中

[DbFunction(FunctionName = "GetDistance", Schema = "dbo")]
        public static int GetDistance(double lngBegin,double latBegin,double lngEnd,double latEnd)
        {
            return Function.CallNotSupported<int>();
        }

2、应用

var list = context.Supermarket.Where(x => MainDbContext.GetDistance(x.Lng, x.Lat, 116.476708, 39.96406) > 50).ToList();
原文地址:https://www.cnblogs.com/flywing/p/9020429.html