ardalis/EFCore.Extensions

Add Extensions to Enable/Disable tracking on a DbContext

开放

#1 创建于 2019年8月6日

 (0 条评论) (0 个反应) (0 位负责人)C# (8 个派生)github user discovery
good first issue

仓库指标

星标
 (44 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

If you want to force the dbContext to make a new db call instead of relying on its identity map, you can do so with this approach:

dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
var fromDb = await dbContext. [whatever query]
dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.TrackAll;

Create extension methods that simply turn off tracking and then turn it back on that require less code than assigning to the QueryTrackingBehavior does.

贡献者指南