CommonLibrary.NET 存储库和 EF 4 一起工作吗?
我想在我的项目中使用 CommonLibrary.NET,但我有遗留代码,无法进行 Code First 建模,我使用 VS2010 工具从数据库生成我的模型。
但设计工具生成的开箱即用实体似乎无法与 CommonLibrary 中的存储库一起使用,它给出了错误:
错误 1 类型“RepositoryTest.UserInfo”不能用作类型 泛型类型或方法中的参数“T” 'ComLib.Entities.RepositorySql
'。没有隐式引用 从“RepositoryTest.UserInfo”转换为 'ComLib.Entities.IEntity'。
有人也遇到过这个问题吗,如果有的话也许有一个简单的解决方案?
我还想知道是否有人有一个好的替代框架或项目来实现支持 EF 实体的存储库。 我是 TDDing,所以我想在同一个框架中实现内存中的存储库,这就是我首先选择这个框架的原因。
I would like to use CommonLibrary.NET in my project but I have legacy code and can't do Code First modeling, I use the VS2010 tool to generate my model from the DB.
But it seems that the out of the box entities that the design tool generated can't be used with the repositories in the CommonLibrary, It gives the error:
Error 1 The type 'RepositoryTest.UserInfo' cannot be used as type
parameter 'T' in the generic type or method
'ComLib.Entities.RepositorySql<T>'. There is no implicit reference
conversion from 'RepositoryTest.UserInfo' to
'ComLib.Entities.IEntity'.
Did anyone had this problem also, if so maybe there is a simple solution?
I would like also to know if anyone have a good alternative framework or project that implements repositories that support EF entities.
I am TDDing so I would like to have an implementation of a repository in memory in the same framework, This was the reason I choose this framework in the first place.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来
ComLib.Entities.RepositorySql
有一个通用约束,类似于这意味着您的实体类必须按顺序实现此接口
ComLib.Entities.IEntity
用作存储库的通用类型参数。所以你的类必须如下所示:It looks that
ComLib.Entities.RepositorySql<T>
has a generic constraint, something likeThis means that your Entity classes have to implement this interface
ComLib.Entities.IEntity
in order to be used as the generic type parameter of the repository. So your class must look like: