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();

 

posted @ 2018-05-10 16:45  随学·笔记  阅读(199)  评论(0编辑  收藏  举报