我使用以下代码进行了测试以更新Product:var existing = await _productRepository.FirstOrDefaultAsync(c => c.Id == input.Id);if (existing == null) throw new UserFriendlyException(L("ProductNotExist"));var updatedEntity = ObjectMapper.Map<Product>(input);var entity = await _productRepository.UpdateAsync(updatedEntity);但这会引发异常:Mvc.ExceptionHandling.AbpExceptionFilter-无法跟踪实体类型'Product'的实例,因为已经跟踪了另一个具有相同'{'Id'}键值的实例。附加现有实体时,请确保仅附加一个具有给定键值的实体实例。这是由查询引起的existing。有什么解决办法吗?
添加回答
举报
0/150
提交
取消