一、IDapper配置
需要先编写一个接口引用Volo.Abp包的IDapperRepository
public interface ISharedDapperRepository : IDapperRepository
{
}
然后在主代码调用接口
private readonly ISharedDapperRepository _sharedDapperRepository;
public xxManager(ISharedDapperRepository sharedDapperRepository){
_sharedDapperRepository = sharedDapperRepository;
}
二、编写sql语句
如下
var sql = new StringBuilder($"SELECT * FROM ** WHERE Id={a}");
三、使用DbConnection查询
//将查询结果存入列表
var list = (await _datPbmDapperRepositpry.DbConnection.
QueryAsync<T>(sql)).ToList();