0
Good morning guys, all right?
I need to control the Dapper transaction using Simplecrud. I have an application in Asp.net core using Dependency Injection.
I will post parts of the code only (removing conversions from Viewmodel to Model and validations) not to be so complex.
but in short, I have the Service>Business>Repository>Base
Service makes the integration of Business when it is necessary the integration between several Business.
In 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);
}
Na Repository
public async Task<T> InsertOnDataBaseAsync(T entity)
{
Tkey id = await _dbConnection.InsertAsync<Tkey,T>(entity);
entity.Id = id;
return entity;
}
When I control with Scope, I get the following error message "Enlisting in Ambient transactions is not supported"
Scope apparently cannot control transactions within Simplecrud.
Someone could help me in this case, I’ve seen examples working, but there was no separation of layers.
In the case of changing Simplecrud, I have the situation of annotating where some columns are not changed in Update, and Simplecrud has the "Dapper.Ignoreupdate" annotation that helps me in this case.
I think that’s it, if anyone can help me.
thank you