Wednesday, May 7, 2008

MVC / LINQ / SubSonic / Entity Framework

When I first started goofing around with MVC.NET a few days ago, I considered looking at the entity framework at the same time. Then I figured that LINQ and MVC.NET would be enough to keep me busy

Tonight, while looking around to find answers to some mvc questions, I came across this:
http://subsonicproject.com/

I watched one of the videos, and its pretty neat. SubSonic generates the DAL layer for you. It can also be setup to regenerate the DAL every time the web site starts. (You wouldn't want to do that in production, but convenient for development). I haven't played with at all; I just watched the video, but its interesting. It looks like PRE-LINQ LINQ. I wonder if LINQ is going to be problem for them.

One nice feature of SubSonic is scripting. It creates an external tool that will script the entire db, including data, so that you can check it in. Cool.

I thought about using SubSonic for some portion of the demo site, but that'd be a pain. Rather than mentally battle over LINQ, Entities, and SubSonic, I'm going to refactor the stuff so it can use any of the three. If it works (it should), it'll allow me to play with all three. (Honestly, though, I don't plan on digging into the entity framework just yet).

I noticed one thing in SubSonic that I wasn't able to do in LINQ (at least not on the first attempt. I only spent 3 seconds on it): Partial classes. In LINQ, as shown in a previous post, I can create a partial class for the dataContext object.

I did this:

List people = _db.GetAllPeople(); //or something like that

I wanted to do:

List people _db.People.GetAllPeople();

As shown, it would have to be a static method, which isn't what I want. So, obviously, its not going to work as intended. But, the subsonic api works differently, and you can create a partial class at the table level.

So, my next task is to create an interface, a factory, and multiple implementations of the interface so that I can play with multiple DAL technologies. Stay tuned.

No comments: