SQL拼接字符串

 string sql = "select * from(select ROW_NUMBER() over(order by CreateTime desc) as number,ID,Name,Size,IsOpen,DownCount,ImgUrl,DownUrl,CreateTime from Source where IsDeleted = 0 ";           

 if (TypeID!=0)      

{                

          sql += "and TypeID=@TypeID";            

}

 sql+= " )as aaa where number between " + ((pageindex - 1) * pagecount + 1) + " and " + pageindex * pagecount;

原文地址:https://www.cnblogs.com/CandyHY/p/6625664.html