[英]Is it possible to refresh the data after insert?
我使用 EF / AutoMapping。 我想在插入后立即记录的 ID(PK)。 你是怎样做的? 插入后是否可以立即刷新数据?
public int InsertArtist(ArtistDto artistDto)
{
Artist entity = _mapper.Map<ArtistDto, Artist>(artistDto);
_artistRepository.Insert(entity);
_artistRepository.Save();
return entity.Id;
}
默认情况下它正在刷新数据,假设您的 Id 是数据库生成的,那么在保存实体后,实体框架将分配和 id 给该实体并返回引用的实体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.