var  info = new List<string>();

ef 查询语句

query.Where(x => info .Contains(x.Barcode))

报错  $  附近错误

这是 ef 为了兼容  ,把查询语句转成了 类似下方语句

where barcode in( SELECT 1
    FROM OpenJson(@__names_0) AS)

解决方法: 重点是添加  o => o.UseCompatibilityLevel(120) 兼容2014数据库

builder.Services.AddDbContext<BaseDbContext>(option =>
{
option.UseSqlServer(builder.Configuration.GetConnectionString("BaseDbContext"), o => o.UseCompatibilityLevel(120));
});




 

posted on 2024-03-28 22:27  滢枫  阅读(20)  评论(0编辑  收藏  举报