There are several ways to retrieve one or more AnswerItems. Choose an appropriate function given the particular scenario:
Get a specific Blog by its ID:
| GetBlog(Guid id) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); if (listOfAllBlogs.Count > 0)
{
// get first blog. This is redundant - just for demonstration
Telerik.Blogs.IBlog firstBlog = (Telerik.Blogs.IBlog)listOfAllBlogs[0];
// get blog by specified ID
Telerik.Blogs.IBlog theBlog = blogManager.GetBlog(firstBlog.ID);
Response.Write(theBlog.Name + "<br />");
}
|
Get all Blogs:
| GetBlogs() |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); if (listOfAllBlogs.Count > 0)
{
foreach (Telerik.Blogs.IBlog blogItem in
listOfAllBlogs)
Response.Write(blogItem.Name + "<br />");
}
|
Get all Blogs, sorted:
| GetBlogs(string sortExp) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs, sorted by Name property, in ascending
order IList listOfAllBlogs = blogManager.GetBlogs("Name ASC"); if (listOfAllBlogs.Count > 0)
{
foreach (Telerik.Blogs.IBlog blogItem in
listOfAllBlogs)
Response.Write(blogItem.Name + "<br />");
}
|
Get all Blogs for the current user, sorted:
If the current user has unrestricted rights, this method returns all blogs, sorted. If current user belongs to a role that does not have restricted rights, and is currently
logged-in, this method will return all his/her blogs.
| GetMyBlogs(string sortExp) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs for current user, sorted by Name
property, in ascending order IList listOfAllBlogs = blogManager.GetMyBlogs("Name
ASC"); if (listOfAllBlogs.Count > 0)
{
foreach (Telerik.Blogs.IBlog blogItem in
listOfAllBlogs)
Response.Write(blogItem.Name + "<br />");
}
|
Get all Blogs, sorted, with specified starting position and number of Blogs to return:
| GetBlogs(int from, int max, string sortExp) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get specific number of blogs, sorted by Name
property, in descending order
// in this case, all blogs will be returned (0,0) IList listOfAllBlogs = blogManager.GetBlogs(0, 0, "Name DESC"); if (listOfAllBlogs.Count > 0)
{
foreach (Telerik.Blogs.IBlog blogItem in
listOfAllBlogs)
Response.Write(blogItem.Name + "<br />");
}
|
Get Blogs with specified IDs:
| GetBlogs(Guid[] ids) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs. This is redundant - just for
demonstration IList listOfAllBlogs = blogManager.GetBlogs(); if (listOfAllBlogs.Count > 0)
{
// create an array of IDs and populate it. This is redundant - just for demonstration
Guid[] blogIDs = new Guid[4];
blogIDs[0] = ((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID;
blogIDs[1] = ((Telerik.Blogs.IBlog)listOfAllBlogs[1]).ID;
// get all blogs with the specified IDs
IList listOfBlogs = blogManager.GetBlogs(blogIDs);
if (listOfBlogs.Count > 0)
{
foreach (Telerik.Blogs.IBlog blogItem in listOfBlogs)
Response.Write(blogItem.Name + "<br
/>");
}
}
|
See Also