@@ -46,20 +46,27 @@ public static async Task<List<T>> InsertWithStrategyAsync<T>(
4646 }
4747
4848 var actualConfigure = configure ?? ( _ => { } ) ;
49- switch ( strategy )
49+ try
5050 {
51- case InsertStrategy . InsertReturn :
52- return dbContext . ExecuteBulkInsertReturnEntities ( entities , actualConfigure , onConflict ) ;
53- case InsertStrategy . InsertReturnAsync :
54- return await dbContext . ExecuteBulkInsertReturnEntitiesAsync ( entities , actualConfigure , onConflict ) ;
55- case InsertStrategy . Insert :
56- dbContext . ExecuteBulkInsert ( entities , actualConfigure , onConflict ) ;
57- return dbContext . Set < T > ( ) . Where ( x => x . TestRun == runId ) . ToList ( ) ;
58- case InsertStrategy . InsertAsync :
59- await dbContext . ExecuteBulkInsertAsync ( entities , actualConfigure , onConflict ) ;
60- return await dbContext . Set < T > ( ) . Where ( x => x . TestRun == runId ) . ToListAsync ( ) ;
61- default :
62- throw new NotImplementedException ( ) ;
51+ switch ( strategy )
52+ {
53+ case InsertStrategy . InsertReturn :
54+ return dbContext . ExecuteBulkInsertReturnEntities ( entities , actualConfigure , onConflict ) ;
55+ case InsertStrategy . InsertReturnAsync :
56+ return await dbContext . ExecuteBulkInsertReturnEntitiesAsync ( entities , actualConfigure , onConflict ) ;
57+ case InsertStrategy . Insert :
58+ dbContext . ExecuteBulkInsert ( entities , actualConfigure , onConflict ) ;
59+ return dbContext . Set < T > ( ) . Where ( x => x . TestRun == runId ) . ToList ( ) ;
60+ case InsertStrategy . InsertAsync :
61+ await dbContext . ExecuteBulkInsertAsync ( entities , actualConfigure , onConflict ) ;
62+ return await dbContext . Set < T > ( ) . Where ( x => x . TestRun == runId ) . ToListAsync ( ) ;
63+ default :
64+ throw new NotImplementedException ( ) ;
65+ }
66+ }
67+ finally
68+ {
69+ dbContext . ChangeTracker . Clear ( ) ;
6370 }
6471 }
6572}
0 commit comments