public async Task <IList <CertificateBatch> > BatchFilter(CertificateBatchFilter filter) { var statusList = new DataTable(); statusList.Columns.Add("Val", typeof(int)); if (filter.Status?.Any() ?? false) { foreach (var status in filter.Status) { statusList.Rows.Add((int)status); } } var param = new DynamicParameters(); param.Add("@From", filter.From); param.Add("@To", filter.To); param.Add("@RequestID", filter.RequestID); param.Add("@Status", statusList.AsTableValuedParameter("dbo.SmallIntType")); return((await SqlMapper.QueryAsync <CertificateBatch>(_unitOfWork.Connection, "SelectCertificateBatch", param, commandType: CommandType.StoredProcedure, transaction: _unitOfWork.Transaction)).Distinct().ToList()); }
public async Task <IList <CertificateBatch> > BatchFullFilter(CertificateBatchFilter filter) { var statusList = new DataTable(); statusList.Columns.Add("Val", typeof(int)); if (filter.Status?.Any() ?? false) { foreach (var status in filter.Status) { statusList.Rows.Add((int)status); } } var param = new DynamicParameters(); param.Add("@From", filter.From); param.Add("@To", filter.To); param.Add("@RequestID", filter.RequestID); param.Add("@Status", statusList.AsTableValuedParameter("dbo.SmallIntType")); var mapper = new CertificateBatchMapper(); return((await SqlMapper.QueryAsync(_unitOfWork.Connection, "SelectCertificateBatchFull", new[] { typeof(CertificateBatch), typeof(Certificate), typeof(Premise), typeof(Premise), typeof(Comment) }, obj => { return mapper.Map(obj[0] as CertificateBatch, obj[1] as Certificate, obj[2] as Premise, obj[3] as Premise, obj[4] as Comment); }, param, splitOn: "ID,CertificateID,PremID,MailPremID,CommentID", commandType: CommandType.StoredProcedure, transaction: _unitOfWork.Transaction)).Distinct().ToList()); }