list = new List();
StringBuilder builder = new StringBuilder();
builder.Append("SELECT * FROM ( ");
builder.Append(" SELECT ROW_NUMBER() OVER (");
if (!string.IsNullOrEmpty(orderby.Trim()))
{
builder.Append("order by T." + orderby);
}
else
{
builder.Append("order by T.ID desc");
}
builder.Append(")AS Row, T.* from Templates_Subjects T ");
if (!string.IsNullOrEmpty(strWhere.Trim()))
{
builder.Append(" WHERE " + strWhere);
}
builder.Append(" ) TT");
builder.AppendFormat(" WHERE TT.Row between {0} and {1} ", startIndex, endIndex);
DataTable table = SqlHelper.ExecuteReader(builder.ToString(), CommandType.Text);
if (table == null || table.Rows.Count == 0)
{
return null;
}
else
{
Templates_SubjectsModel templates_SubjectsModel = null;
foreach (DataRow row in table.Rows)
{
templates_SubjectsModel = new Templates_SubjectsModel();
templates_SubjectsModel.Id = (int)table.Rows[0]["ID"];
templates_SubjectsModel.Titles = (string)table.Rows[0]["titles"];
templates_SubjectsModel.Scores = (int)table.Rows[0]["scores"];
templates_SubjectsModel.AddTime = (DateTime)table.Rows[0]["addTime"];
templates_SubjectsModel.IsDel = (int)table.Rows[0]["isDel"];
list.Add(templates_SubjectsModel);
}
return list;
}
}