How to incorporate word press theme in my Razor Blog

Hello friends,
As you know currently I am working on Razor. So I am trying to make a WordPress blog with Razor.Net.
Now the challenging task for me is design. I am not so good in designing so it’s a big deal for me. I just thought to download the WordPress theme and incorporate in My Blog work. So thanks to  free word press themehttp://www.freewordpressthemes4u.com/category/technology) I just downloaded the technology themes from there you can visit and see the other design.I like Mac Doc wordpress theme so here is the steps which I followed which help you also.
1) Just downloaded  the theme from any free wordpress theme sites
2) Copy all the images in your image folder of site
3) Copy CSS file in your Style folder.
4) Now open your site Layout page
5) Replace the body part of your site layout with default preview page of word press theme which you are looking currently. In my Case (free Mac theme page)
6) Then try make pieces of your design like  in my case on the default page there is a header part, footer part,  Search Box part, Archive Part, Center part (Where we will see post),Tag part, Category part.
7) So what I did I created all this part as a separate page like header.cshtml, footer.cshtml, SearchBox.cshtml, Archive.cshtml, Deafult.cshtml, TagSearch.cshtml, CategorySearch.cshtml.
8) Just cut the part from your site layout for specific items like header, site bar, content, category etc.
9) In SiteLayout page only call this pages. This is the simplest way.
10) Now if I need to incorporate any other Word press theme then I just needs to copy the theme and just need to replay site layout. This is the simplest way I found with Razor.


11) The best part is I just need to create a page cshtml and can place anywhere according to need and it will work like a word press functionality.

I hope you got some idea.
Soon I am going to upload the Blog which will help you to understand the concept of Razor more. It’s a simplest blog creation.
Thanks
Rajat Jaiswal

Advertisements

Simpletest way to fetch database records in Razor

Hello friends,
Today we are discussing how to fetch data from database in Razor.
You can connect with database using database.open() method.
This will return you database object.
For example
Database dbCon = Database.Open(“MyBlog”);

Now to fetch records from database you have mainly three methods which are
1) dbCon.Query() :- This method return IEnumeration object. You can use this method. Or in the other words it will return no of record sets which are available after running the specific query.
2) dbCon.QuerySingle():- By the name it will return single record set or single object. You can use it when you are sure the query will return single result set.
3) dbCon.QueryValue() :-
  This method is like your scalar method in ADONET. It will return scalar value or single value.

Here I am taking example of fetching multiple rows from a table.
Suppose I have a tag table and I need to fetch records from database and display it in a tabular html format. Then below are the steps.
1) Create database object
Database dbCon = Database.Open("MyBlog");
2) Get IEnumerable object  by query
var TagListRecords = dbCon.Query("SELECT * FROM lkuTag");
3) Run for loop on IEnumerable object  and print the columns of table result set
@foreach (var tagrecord in TagListRecords) {
<TR>
<TD>@tagrecord["lngId"]</TD>
<td>&nbsp;</td>
<TD>@tagrecord["Tag"]</TD>
</TR>
}

You will get following screen after running it.

I hope it is simplest way to fetch records.

In next topic we will discuss how to insert records in database in razor.

Till than thanks a lot.

Take care
Rajat Jaiswal