TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Getting number of comments from server object model using SocialCommentManager class
Prasham Sabadra
Apr 11
2015
Code
1.5
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
//using Microsoft.Office.Server.SocialData; - include this for SocialCommentManager
// Variable declaration
private
SocialCommentManager _commentManager =
null
;
private
Uri _currentUri =
null
;
_siteId = SPContext.Current.Site.ID;
_webId = SPContext.Current.Web.ID;
SPSecurity.RunWithElevatedPrivileges(
delegate
()
{
using
(SPSite site =
new
SPSite(_siteId))
{
using
(SPWeb web = site.OpenWeb(_webId))
{
_url = HttpContext.Current.Request.Url.ToString();
//Create Service Context
SPServiceContext _serviceContext =
SPServiceContext.GetContext(web.Site);
if
(!
string
.IsNullOrEmpty(_url))
{
_currentUri =
new
Uri(_url);
//Initialize SocialCommentManager
_commentManager =
new
SocialCommentManager(_serviceContext);
if
(_currentUri !=
null
)
{
_totalComments =
_commentManager.GetCount(_currentUri);
}
}
}
}
});
SocialCommentManager
Getting no of comments for current url