Skip to content

Instantly share code, notes, and snippets.

Created December 29, 2010 20:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Exploring blog posts using Sitefinity's Fluent API
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomWidget.ascx.cs" Inherits="SitefinityWebApp.Custom.CustomWidget" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<div class="customwidget">
<div><asp:Button ID="CreateBlog" runat="server" Text="Create Blog"
onclick="CreateBlog_Click" /></div>
<div><asp:Button ID="CreatePosts" runat="server" Text="Create Posts"
onclick="CreatePosts_Click" /></div>
<div><asp:Button ID="DisplayPosts" runat="server" Text="Display Posts"
onclick="DisplayPosts_Click" /></div>
<telerik:RadGrid ID="RadGrid1" Width="100%" runat="server">
<MasterTableView AutoGenerateColumns="False">
<telerik:GridBoundColumn DataField="Title" HeaderText="Title" />
<telerik:GridBoundColumn DataField="Parent.Title" HeaderText="Blog" />
<telerik:GridDateTimeColumn DataField="DateCreated" HeaderText="Date Created" />
<telerik:GridBoundColumn DataField="Comments.Count" HeaderText="Comments" />
using System;
using Telerik.Sitefinity;
namespace SitefinityWebApp.Custom
public partial class CustomWidget : System.Web.UI.UserControl
protected void CreateBlog_Click(object sender, EventArgs e)
App.WorkWith().Blog().CreateNew().Do(b => b.Title = "My New Blog").SaveChanges();
protected void CreatePosts_Click(object sender, EventArgs e)
using (var fluent = App.WorkWith())
var blog = (from b in fluent.Blogs()
where b.Title == "My New Blog"
select b).First();
for (int i = 0; i < 10; i++)
blog.CreateBlogPost().Do(p => p.Title = "Blog Post " + i).SaveChanges();
protected void DisplayPosts_Click(object sender, EventArgs e)
var posts = from p in App.WorkWith().BlogPosts()
where p.Parent.Title == "My New Blog"
orderby p.Title
select p;
RadGrid1.DataSource = posts.Get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment