1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/// <summary> /// 更新点击量 /// </summary> /// <param name="id"></param> /// <param name="num"></param> public void UpdateHits(int id, int num) { const string sql = @"update articles set hits+=@Hits where id=@Id"; object[] args = { new SqlParameter { ParameterName = "@Hits", Value = num}, new SqlParameter { ParameterName = "@Id", Value=id} }; _db.Database.ExecuteSqlCommand(sql, args); } |