Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Updates the view count of a post.
- /// </summary>
- /// <param name="postId">The Id of the post to update</param>
- public bool UpdateViewCount(int postId)
- {
- Repository repository = new Repository();
- Post p = repository.Posts.Where(p => p.Id == postId).SingleOrDefault();
- if (p != null)
- {
- p.Views++;
- }
- repository.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
- }
- UPDATE table SET views=views+1 WHERE myId=12;
- _db.ExecuteCommand("UPDATE posts SET views=views+1 WHERE id={0}", postId);
Add Comment
Please, Sign In to add comment