如何使用NOLOCK读取/选择Entity Framework核心?(避免OLTP数据库中的锁定/阻塞/死锁)。这是一个示例select查询。
var data= _dbContext.Set<ProductOrder>()
.Where(c => c.ProductTypeId == this.productTypeId && c.saleYear == this.saleYear)
.ToList();将Net Core 3.1与SQL Server 2016数据库配合使用。
发布于 2020-08-27 02:27:42
可以将NOLOCK与EF Core一起使用,如下所示
using (new TransactionScope(TransactionScopeOption.Required, new TransactionOptions
{
IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
}))
{
using (var db = new YourDbContext())
{
var data = db.Set<ProductOrder>()
.Where(c => c.ProductTypeId == this.productTypeId && c.saleYear == this.saleYear)
.ToList();
}
}https://stackoverflow.com/questions/63603503
复制相似问题