So, I decide to rebuild a new solution. I will carry on the membership layer later cause I want a system who could use Sql, Active Directory or OpenID for the login and only use Sql for the membership role. I have an idea to do that but as I told you in a previous post, a security layer is a kind of plugin. Therefore, we could add it later.
Today, I will show you how I am going to create the models and prepare my data access with the help of LinqToSql class.
I choose to make Kiwi multilingual.
I am not a dba, you are welcome with your feedback.
Here is the design I choose :

I decided to create five objects to begin the project. An object Post, Page, Comment, Tag and Category.
Example for Page:
I use the LazyList pattern (more info here). I will put the project on codeplex, like this, you will able to browse and download the code.
namespace KIWI.MVC.Data
{
class Page
{
public int PageID { get; set; }
public string Author { get; set; }
public string Status { get; set; }
public DateTime Date { get; set; }
public DateTime ModifiedDate { get; set; }
public string Version { get; set; }
public string Permalink { get; set; }
public string Password { get; set; }
public LazyList<Page> PageChild{ get;set;}
public LazyList<Page> PageLozalized { get; set; }
}
public class PageLocalized
{
public string Title { get; set; }
public string Text { get; set; }
public string Excerpt { get; set; }
public string LanguageCode { get; set; }
}
}
This repository will be the link between my object and my db. It will contain all the main method I need. I will always return an IQueryable type. It will allow you to use the pipeline pattern to create some filter functions.

After creating the linq to sql class, drop the table you need from the server explorer of visual studio to the dml file.

You will have the representation of you db (like the first page of this post). After, change some properties of you LinqCMSRespository class. Double clik on the LinqCMDRespository.dbml and right click on the screen where your tables appear. Here change the Name to “DB”. It is only to use the same name for you future dbml and improve the visibilty of your code.

Build you solution to see if everything goes well.
If you have built successfully, then create you SqlCMSRespository class.
Here is the code :
using CMS.MVC.Data.SqlRepository;
namespace CMS.MVC.Data
{
class SqlCMSRespository
{
//the name we changed in the properties of our Linq to Sql class
private DB _db;
//constructor
#region .ctor
//we instanciate the db when we instantciate the SqlCMSRespository
//default constructor
public SqlCMSRespository()
{
_db = new DB();
}
public SqlCMSRespository(DB dataContext)
{
//override the current context with the on passed in
//for TDD
_db = dataContext;
}
#endregion
#region Post
//there we will put our main functions like GetPost(),...
//But before, let's go to TDD !!!!
//TEST DRIVEN DESIGN
#endregion
}
}
Now we are able to begin all our data access method but before writing some code in your repository, we’ll go with the TDD approach.
And by creating our tests, we will see what we need in our application.
So this is the end for today, as usual, feedback and comments are very appreciated.