views:

201

answers:

2

Does anyone have an example of using LightSpeed with the Repository Pattern using interfaces and dependency injection?

A: 

I don't have an example fro you off-hand, but I can tell you that I stumbled across something of a nasty when implementing my own Repository pattern with Lightspeed on an ASP.NET MVC project.

Lightspeed does not allow you to manually assign the primary key value of an entity (at least not without some hairy work-arounds invokving either reflection or hard-coding every entity), which means that in a Repository pattern, you can't simply pass in an entity and ask the Respository to update the database for you, because that entity that you pass it won't have it's primary key set (because the calling code can't set the primary key!).

Like I said there are work-arounds if you're heart-set on Lightspeed. Otherwise, consider an ORM that implements true POCO's, like Entity Framework, NHibernate or Linq2SQL. There are plenty of examples of setting up a repository pattern using these ORMs on the net.

Mark
Thank you for the comment. We did end up abandoning the framework. Luckily I'm no longer working on that project any more and that was my last project that used .NET. I'm back to using ruby again and I am once again happy to be working with flexible frameworks.
dsapala
A: 

A better answer would be from the MindScape guys, here is a post they'll answer shortly: http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=3535

Jeremy Thompson