I'm using EF/Automapping. An error occurs with a Foreign Key. With a try...catch, I want to catch the error. And I want to go further by inserting / updating data.
But I have the idea the process stays in the same exception. It looks the same as LINQ-to-SQL. That the SaveChanges-method try to save all updates who are waiting in the stack for saving.
Is it possible to clear a save-process?
The Insert-method in the LogMessagesService
public int Insert(LogBerichtDto LogBerichtDto)
{
LogBericht entity = _mapper.Map<LogBerichtDto, LogBericht>(LogBerichtDto);
_logBerichtRepository.Insert(entity);
_logBerichtRepository.Save();
return entity.Id;
}
In GenericRepository
public void Save()
{
_context.SaveChanges();
}
When I have time work on my own application, I can find out what's the problem? The were several problems. But the main problem I think the not saved changes stays in cache.
And the remark of Gert Arnold is the way I solved it.
This is my code of the GenericRepository. Not an Injection of the context anymore. And create new when needed. You can shoot. But the Import process is not hanging anymore.