LightSpeed with IoC/Dependency Injection using Repository Pattern [closed]
Does anyone have an example of using LightSpeed with the Repository Pattern using interfaces and dependency injection?
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.
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
精彩评论