예제 #1
0
        public static async Task WrapInTransaction(this TodosDbContext todosDbContext, Action action, CancellationToken cancellationToken)
        {
            await using var transaction = await todosDbContext.Database.BeginTransactionAsync(cancellationToken);

            action();
            await todosDbContext.SaveChangesAsync(cancellationToken);

            await transaction.CommitAsync(cancellationToken);
        }
예제 #2
0
 public static IQueryable <TodoList> TodoListsWithItems(this TodosDbContext todosDbContext)
 {
     return(todosDbContext.TodoLists.Include(list => list.TodoItems));
 }