开发者

LightSpeed with IoC/Dependency Injection using Repository Pattern [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_如何转开发Closed 10 years ago.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜