无法使用 EF 4 CTP5 存储库模式插入记录
我正在使用解释的存储库模式 这里,在控制台应用程序中(只是为了感受它是如何工作的),似乎我犯了一些基本错误。
我使用 Unity 来初始化 IoC,如下所示:
var container = new UnityContainer();
container
.RegisterType<Abstract.IUnitOfWork, Concrete.UnitOfWork>()
.RegisterType<Abstract.IDatabaseFactory, Concrete.DatabaseFactory>( );
我注意到 DatabaseFactory 始终返回处于断开状态的数据库..是这样吗? (我稍后将重点放在 WPF 应用程序中使用它!)
我确信我错过了一些东西......
I'm using the repository pattern explained here, in a Console application (just to get the feeling of how it works) and is seems i make some fundamental error.
I'm using Unity to initialize the IoC like this:
var container = new UnityContainer();
container
.RegisterType<Abstract.IUnitOfWork, Concrete.UnitOfWork>()
.RegisterType<Abstract.IDatabaseFactory, Concrete.DatabaseFactory>( );
I noticed that the DatabaseFactory returns always a Database which is in a disconnected state..is that right? (I 'm focusing on using this later in a WPF application!)
I'm sure i'm missing something....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IoC 初始化几乎是正确的!我遇到的问题是由于我错误地定义了一对一关系。这导致了插入问题!
所以我想这件事现在已经结束了!
The IoC initialization was almost correct! The problem i got was due to the fact that i had wrongly defined a one-to-one relation. This caused insertion problems!
So i guess this matter is closed now!