在PocoData 对象中,可以定义一个数组类型的属性来表示 IN
参数,然后在构建 SQL 查询语句时,将该数组作为参数传递给 Dapper。
代码示例:
public async Task<int> GetCountBInterfaceIdsAsync(long memberId, string interfaceIds)
{
string[] idArray = interfaceIds.Split(',');
PocoData data = PocoData.ForType(typeof(APIOrder), new ConventionMapper());
Sql sql = Sql.Builder;
sql.Select("count(1)");
sql.From(new object[] { data.TableInfo.TableName });
sql.Where("Status>=0 and MemberId=@0 and InterfaceId in (@1)", memberId, idArray);
return await CreateDAO().FirstOrDefaultAsync<int>(sql);
}