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); }
public static IQueryable <TodoList> TodoListsWithItems(this TodosDbContext todosDbContext) { return(todosDbContext.TodoLists.Include(list => list.TodoItems)); }