谁能帮我翻译下面这段代码,有关asp.net的,谢谢了
publicDataSetGetListByPage(stringstrWhere,stringorderby,intstartIndex,intendIndex){St...
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("SELECT * FROM ( ");
strSql.Append(" SELECT ROW_NUMBER() OVER (");
if (!string.IsNullOrEmpty(orderby.Trim()))
{
strSql.Append("order by T." + orderby );
}
else
{
strSql.Append("order by T.ID desc");
}
strSql.Append(")AS Row, T.* from News T ");
if (!string.IsNullOrEmpty(strWhere.Trim()))
{
strSql.Append(" WHERE " + strWhere);
}
strSql.Append(" ) TT");
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
return DbHelperOleDb.Query(strSql.ToString());
} 展开
{
StringBuilder strSql=new StringBuilder();
strSql.Append("SELECT * FROM ( ");
strSql.Append(" SELECT ROW_NUMBER() OVER (");
if (!string.IsNullOrEmpty(orderby.Trim()))
{
strSql.Append("order by T." + orderby );
}
else
{
strSql.Append("order by T.ID desc");
}
strSql.Append(")AS Row, T.* from News T ");
if (!string.IsNullOrEmpty(strWhere.Trim()))
{
strSql.Append(" WHERE " + strWhere);
}
strSql.Append(" ) TT");
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
return DbHelperOleDb.Query(strSql.ToString());
} 展开
2个回答
展开全部
方法内是sql语句的一个拼接,select * from (select row_Number() over( order by 按什么字段排序) as Row,T.* from News T where +查询条件)TT where TT.Row between{0} and{1}
order by if判断:如果有指定的排序字段,则按指定的排序字段排序,没有指定默认的按ID排序; row_Number() over:重新排序生成新列; strWhere if 判断:有条件就添加where 条件,否加; between and 左右的占位符,是指定的beteen 语法区间条件。
order by if判断:如果有指定的排序字段,则按指定的排序字段排序,没有指定默认的按ID排序; row_Number() over:重新排序生成新列; strWhere if 判断:有条件就添加where 条件,否加; between and 左右的占位符,是指定的beteen 语法区间条件。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询