Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Saving Created Event Handlers #23


User avatar
0
daniel created

Is it possible to write to the database once an Entity has been created? Since the connection has been closed _repository.insert(...) will not save any changes, and initiating a new DB connection throws me a "The current TransactionScope is already complete" error.

Am I missing something obvious?

Code below:

private readonly IRepository<ActivityLog> _activityLogRepository;

		public ActivityLogWriter(IRepository<ActivityLog> activityLogRepository)
		{
			_activityLogRepository = activityLogRepository;
		}

		public void HandleEvent(EntityCreatedEventData<Comment> eventData)
		{
			_activityLogRepository.Insert(new ActivityLog
			{
				Message = "Something about the inserted entity"
			});
		}

2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    It's similar to: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/380">https://github.com/aspnetboilerplate/as ... issues/380</a>

    Yes, there is a problem about that. I will fix it soon.

  • User Avatar
    0
    daniel created

    Thanks for the reply! Would explain why I was getting nowhere with it.