aspnetboilerplate: update() method Bug

firstly, if I get a enetity used AsNoTracking() . just like that: return await this.Context.BailunOrders.AsNoTracking().Where(a => a.OriginOrderNo == originNo.Trim()).FirstOrDefaultAsync(); and if I use Update(entity) to update the entity defined in IRepository but it doesnt work ~ that didn’t change value in database . finally I have to define a new Update method to resovle the issue

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Design a value object as immutable (like the Address above) if there is not a good reason for designing it as mutable.

The alternative: “detach the previous owned entity entry first

var context = (_bailunOrderRepository as IRepositoryWithDbContext).GetDbContext();
context.Entry(order.Buyer).State = EntityState.Detached;
context.Entry(order.PayMentInfo).State = EntityState.Detached;