示例#1
0
        public TodoAggregateRoot Rebuild(Guid aggregateId)
        {
            var root = this.context.Set <TodoAggregateRoot>().FirstOrDefault(x => x.AggregateId == aggregateId);

            context.Attach(root);
            return(root);
        }
示例#2
0
        public async Task <IActionResult> OnPostUpdateAsync()
        {
            _db.Attach(TodoItem).State = EntityState.Modified;
            await _db.SaveChangesAsync();

            return(RedirectToPage());
        }
示例#3
0
        public async Task <TodoItem> AddAsync(Collection collection, TodoItem item)
        {
            _database.Attach(collection);
            collection.TodoItems.Add(item);
            await _database.SaveChangesAsync();

            return(item);
        }
示例#4
0
        public async Task <int> RemoveItem(int id)
        {
            var item = new TodoItem
            {
                Id = id
            };

            _context.Attach(item);
            _context.Remove(item);
            return(await _context.SaveChangesAsync());
        }
示例#5
0
 public void UpdateTodo(Todo todo)
 {
     _context.Attach(todo);
     _context.Entry(todo).State = EntityState.Modified;
     _context.SaveChanges();
 }