public bool commupfos(commselect commID) { string sql = "UPDATE [comments] SET [shown] = '2' WHERE ID = {0}"; int orders = db.Database.ExecuteSqlCommand(string.Format(sql, commID.ID)); if (orders > 0) { return(true); } else { return(false); } }
//查询评论 public List <commselect> commselect(string mentsname) { commselect i = new commselect(); StringBuilder sql = new StringBuilder("select a.ID,a.userID,a.ProductID,a.mentsname,a.[Time],a.shown,b.name from comments a left join Addship b on a.userID=b.[UID] where 1=1"); if (!string.IsNullOrEmpty(mentsname)) { sql.Append(" and b.Name like '%" + mentsname + "%'"); } List <commselect> orders = db.Database.SqlQuery <commselect>(sql.ToString()).ToList(); sql.Append("order by [Time] desc"); return(orders); }