I dont want to update value booking.Price in database (Postgrsql) but it is getting updated.I have following code
......... public async Task<AppResponse<UpdateBookingCommandResponse>> Handle(UpdateBookingCommand request, CancellationToken cancellationToken){ var booking = await _bookingRepository.GetByGuIdAsync(request.Id); booking.Price = request.Price; var response = _mapper.Map<UpdateBookingCommandResponse>(booking); return Ok(response); }...........
Request body
public class UpdateBookingCommand: AppRequest<UpdateBookingCommandResponse>, IAuditableRequest {....... public List<Product> Products { get; set; } public List<Location> PickupLocations { get; set; } public decimal OriginalPrice { get; set; } public decimal Price { get; set; } public decimal Cost { get; set; }..... }
Response Body
public class UpdateBookingCommandResponse {......... public decimal OriginalPrice { get; set; } public decimal Price { get; set; } public decimal Cost { get; set; } public decimal PaidAmount { get; set; }...... }
Booking Class
public class Booking: BaseEntity {...... public decimal OriginalPrice { get; set; } public decimal PriceCore { get; set; } public decimal Price { get; set; } public decimal PriceGst { get; set; }....... }
If you don't want updated the value use AsNoTracking, this function disable the modification's tracking by dbcontext and their update when you call db.saveChange()
like this db.booking.AsNotTracking().where(b => b.id == id)
also next time share the function's code to get booking
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.