ABP executed sql statement

As business red tape, too much trouble with EF, need to use sql statement, then the Internet for a long time, examples are found in the old version, the new version has the first statement has been removed, it can not be used

Here to be a small mind

First instance injection

 private readonly IDbContextProvider<AbpProjectDbContext> _dbContextProvider;

Then add the code in the method needs to execute sql statements in

1   string sql = "sql语句";
2             var result = await _dbContextProvider.GetDbContext().Database.ExecuteSqlCommandAsync(sql);
3             await _dbContextProvider.GetDbContext().SaveChangesAsync();

Note that this can only result Bool return type of the entity to return remains to be studied, to be continued ....

 

Guess you like

Origin www.cnblogs.com/LmuQuan/p/11233621.html