Thursday, March 17, 2011

Just some links around Umbraco, Razor, and data access.
http://joeriks.wordpress.com/2011/01/23/data-the-easy-way-webmatrix-data-in-umbraco/

Wednesday, March 16, 2011

Simple.data

https://github.com/markrendle/Simple.Data/wiki/Finding-data

After listening to a podcast on Simple.Data I decided to check it out for a small project I was working on.
I like it and it works well for small sites that need an active record patten and more.

My first piece of advice is to use NuGet to add the libraries to your solution.  I don't think the download on the site gives you the latest version. Second,  understanding the dynamic type in C# 4.0 is helpful.

See Mark's wiki to see how simple.data works.

I had a design issue and here is how I worked around it.  I had properties in my class that were not defined in my database.  There may be an override to stop the errors.  My solution was to create a private class that was the same name as my table that only had the properties from the database.  Then I created a very simple mapping method. I could have used something dynamic, or named arguments, but I figured with a private class in my repository would give me flexibility to do things like datetime corrections and sure enough that happened.

Why go through all that?  Why not use NHibernate and be done. My application is going to be plugged into a CMS system and I do not know if the NHibernate session would play nicely with hosting package and I don't have time to find out.

https://github.com/markrendle/Simple.Data/wiki/Finding-data