日期:2014-05-17 浏览次数:20529 次
@model List<CEALER.MVC.Models.Blog>
public ActionResult Index()
{
Blog b = new Blog();
List<Blog> list = b.GetBlog(1);
//b.GetNewModel();
return View(list);
}
/// <summary>
/// 获取前n条实体集合
/// </summary>
/// <returns></returns>
public List<Blog> GetBlog(int n)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top " + n + " id,CreateUser,CreateTime,Pushed,Treaded,Commented,Wechated,Published,Title,SummaryText,SummaryImg,DetailContent ");
strSql.Append(" FROM [Blog] ");
DataSet ds = CEALER.Helper.MsSqlHelper.Query(strSql.ToString());
if (ds.Tables[0].Rows.Count > 0)
{
List<Blog> b = new List<Blog>();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Blog b_Child = new Blog();
if (ds.Tables[0].Rows[i]["id"] != null && ds.Tables[0].Rows[i]["id"].ToString() != "")
{
b_Child.id = long.Parse(ds.Tables[0].Rows[i]["id"].ToString());
&