SQL query + statistics

sql uses the same condition: give statistics page and query content 

public List<MyInfo>  Get_MyInfoList(string name,string address,string gender,out int total)
{
List<MyInfo> myInfoList=new List<MyInfo>();
try
{
 IDbShell shell = Common.GetIDbShell(ActionType.Read);
 string sqlDetails=@"select a.code,a.name,a.`no` ,b.address,GROUP_CONCAT(distinct ifnull(a.`name`,a.`no`)) as username,GROUP_CONCAT(distinct b.no) as  infono from registinfo a
	            inner join userinfo b on a.code=b.org_code and b.`status`='A'   
	            inner join reluser c on c.no=a.no and c.`status`='A'
	            left join  trueuser d  on d.no=a.`no` and d.`status`='A'	          
	            left join  user_detail as e on e.no=a.`no` e.`status`='A'
	            where e.`status`='A' and ( e.code like  CONCAT(@0,'.','%') or e.code =@0) 
                 and (@1 is null) or (a.`name` like concat('%',@1,'%'))
                 and (@2 is null) or (a.`gender` like concat('%',@2,'%'))
              group by no;";
string sqlCount="select count(1) from ("+sqlDetails+")  as  total;";
sqlDetails=sqlDetails+"limit @3,@4;";
DataSet ds = shell.ExecuteQueryDataSet(sqlDetails+ sqlCount, code, name, gender,(pageIndex - 1) * pageSize, pageSize);
total = int.Parse(ds.Tables[0].Rows[0][0].ToString());
foreach(DataRow item in ds.Tables[1].Rows)
{
//遍历
}
}
catch(Exception ex)
{
throw ex;
}
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324454046&siteId=291194637