【发布时间】:2020-12-30 04:08:45
【问题描述】:
我有简单的代码,我希望查询超时以测试我的异常日志记录,因此我使用 context.Database.SetCommandTimeout() 方法,提供 1 个刻度的最小值,但查询不会超时并从数据库。
我的 EF 版本是 EF Core 3.1.8。
代码如下所示:
await using var context = new CriusCommissionsDatabaseContext(_config);
context.Database.SetCommandTimeout(TimeSpan.FromTicks(1));
var saleSegments = await context.BSaleSegment
.Include(x => x.Sale)
.Where(x => x.Sale.CorrelationId == correlationId)
.ToListAsync();
【问题讨论】:
标签: c# .net-core entity-framework-core ef-core-3.1