We've finished the Linq Provider of kooboo content repository. Here I will release some code to demonstrate how to use it.
1. Iterate the contents of folder without any data rule or content service API:
Code:
<ul>
<% foreach (var item in (new FolderContentQueryable("Category")))
{%>
<li>
<%= Html.PageLink(item["Title"].ToString(),"category",new {ContentId= item["ContentId"]}) %>
</li>
<%}%>
</ul>
2. Get the content count of folder:
Code:
<%= (new FolderContentQueryable("Category")).Count()%>
3. Query content by content id and folder:
Code:
<%= (new FolderContentQueryable("Category")).OrderBy(cd=>cd.GetColumn<int>("ContentId")).First()["Title"]%>
4. Query content by content id and schema:
Code:
<% var category = (new SchemaContentQueryable("Category")).Where(cd => cd.GetColumn<int>("ContentId") == ContentId); %>
5. Query contents by category and folder:
Code:
<ul>
<% foreach (var item in (new ContentByCategoryNFolderQueryable(ContentId, "News")))
{%>
<li>
<%= Html.PageLink(item["Title"].ToString(), "newsDetail", new { UserKey = item["UserKey"] })%>
</li>
<%}%>
</ul>
6. Query sub contents:
Code:
<ul>
<% foreach (var item in (new SubContentQueryable((int)content["ContentId"], "Comment")))
{%>
<li>
<%=item["Title"]%>
<%=item["Body"]%>
</li>
<%}%>
</ul>
There are series queryable types to support varied query types.
FolderContentQueryable
SchemaContentQueryable
ContentByCategoryNFolderQueryable
ContentByCategoryNSchemaQueryable
CategoryByContentNFolderQueryable
CategoryByContentNSchemaQueryable
SubContentQueryable
Regards,
Jifeng Huang
Kooboo Team
Microsoft ASP.NET MVP