Good morning everyone, alright?
I need to control the Dapper transaction using SimpleCrud. I have an application in asp.net core using Injection Dependency.
I'll post parts of the code only (removing ViewModel to Model conversions and validations) so it does not get so complex.
But in summary, I have the Service > Business & Repository & Base
Service integrates Business when integration between multiple Business is required.
Na service
public async Task SaveAsync(CourseViewModel courseViewModel)
{
using (var transaction = new TransactionScope())
{
await this._courseBusiness.SaveAsync(courseViewModel);
transaction.Complete();
}
}
}
In Business
public async Task SaveAsync(CourseClassViewModel courseClassViewModel)
{
await this._courseClassRepository.InsertAsync(courseClassViewModel);
}
In the Repository
public async Task<T> InsertOnDataBaseAsync(T entity)
{
Tkey id = await _dbConnection.InsertAsync<Tkey,T>(entity);
entity.Id = id;
return entity;
}
When I do the control with Scope, I get the following error message "Enlisting in Ambient transactions is not supported"
Apparently Scope can not handle transactions within SimpleCrud.
Someone could help me in this case, I've seen examples working, but there was no layer separation.
In the case of changing SimpleCrud, I have the situation of making annotations where some columns are not changed in Update, and SimpleCrud has the annotation "Dapper.IgnoreUpdate" that helps me in that case.
I think that's it, if anyone can help me.
Thank you