Is it possible to refresh the data after insert?

131 views Asked by At

I work with EF / AutoMapping. And I want after an Insert immediately the Id (PK) of the record. How do you do that? Is it possible refreshing the data immediately after an insert?

public int InsertArtist(ArtistDto artistDto)
{
    Artist entity = _mapper.Map<ArtistDto, Artist>(artistDto);

    _artistRepository.Insert(entity);
    _artistRepository.Save();

    return entity.Id;
}
1

There are 1 answers

0
Arkaprava Sinha On

By default it is refreshing the data, suppose your Id is Database Generated, then after saving the entity, entity framework will assign and id to that entity and will return the referenced one.