List作为查询条件
public List<tm_master_commodity> SelectCommodity(List<int> CommodityID) { var sql = @"select CommodityID, MemberID, BarCode,CommodityCode,CommodityName from tm_master_commodity WHERE CommodityID IN @CommodityID "; return DbSession.Query<tm_master_commodity>(sql,new { CommodityID } ).ToList(); }
参数的模糊查询
public List<tm_master_syscompany> SelectCompany(string CompanyCode, string Name) { var sql = @"select ID, CompanyCode, Name from tm_master_syscompany where CompanyCode like @companyCode and Name like @companyName "; return DbSession.Query<tm_master_syscompany>(sql, new { companyCode = $"%{CompanyCode}%", companyName = $"%{Name}%" }).ToList(); }
参数查询
public List<tl_im_tasklog> TaskLogQuery(long AbnormalMonitoringID) { var sql = @"SELECT AbnormalMonitoringID, OperateBy, OperateDate, OperateMemo FROM `tl_im_tasklog` WHERE AbnormalMonitoringID=@AbnormalMonitoringID "; return DbSession.Query<tl_im_tasklog>(sql, new { AbnormalMonitoringID= AbnormalMonitoringID }).ToList(); }