【发布时间】:2022-01-17 04:42:04
【问题描述】:
我的要求是从数据库中获取最大数量并添加 +1 以使其不同。我可以使用自增ID,但根据要求不同
try
{
logger.LogInformation($"Patient registered successfully");
var patient = mapper.Map<Patient>(patientCreateDTO);
await _context.Patient.AddAsync(patient);
await _context.SaveChangesAsync();
return CreatedAtAction("GetPatient", new { id = patient.Id }, patient);
}
catch (Exception e)
{
logger.LogError(e, $" Error performing post in {nameof(PostPatient)}");
return StatusCode(500, Messages.Error500Message);
}
【问题讨论】:
标签: .net-core asp.net-core-webapi asp.net-core-6.0 ef-core-6.0