ardalis/EFCore.Extensions

Add Extensions to Enable/Disable tracking on a DbContext

オープン

#1 opened on 2019/08/06

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)C# (8 件のフォーク)github user discovery
good first issue

Repository metrics

Stars
 (44 個のスター)
PR merge metrics
 (30d に merged 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.

コントリビューターガイド