为什么这一行通用代码适用于一个实体对象而不适用于另一个实体对象?
我在使用 http://www.codeproject.com/ 的通用存储库时遇到一些问题KB/architecture/RepositoryUnit.aspx
在“FetchEntityName”中有一行代码,对于某些实体似乎会崩溃,而对于其他一些实体则不会,它们都以同样的方式变得艰难!
我将范围缩小到这个返回 false 的手表表达式。 (我将 18 作为索引器,因为它是似乎运行不佳的实体(组)之一)
typeof(IQueryable<>).MakeGenericType(typeof(T)).IsAssignableFrom(this.ObjectContext.GetType().GetProperties()[18].PropertyType)
返回 false! 左侧:
typeof(IQueryable<>).MakeGenericType(typeof(T))
在手表中返回:
{Name = "IQueryable`1" FullName = "System.Linq.IQueryable`1[[Domain.Groep, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"} System.Type {System.RuntimeType}
右侧:
this.ObjectContext.GetType().GetProperties()[18].PropertyType
在手表中返回:
{Name = "ObjectSet`1" FullName = "System.Data.Objects.ObjectSet`1[[Contacts.Groep, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"} System.Type {System.RuntimeType}
英文?
为什么对于我的 EDMX 中的某些实体,ObjectSet 和 IQueryable 不能相互分配?
I'm having some troubles using the Generic repository of http://www.codeproject.com/KB/architecture/RepositoryUnit.aspx
There is a line of code in "FetchEntityName" that seems to crash for some entities and not for some other entities, they are all made the same way tough!.
I narrowed it down to this watch expression returning false. (i took 18 as an indexer because that's one of the entities (Group) that doesn't seem to work well)
typeof(IQueryable<>).MakeGenericType(typeof(T)).IsAssignableFrom(this.ObjectContext.GetType().GetProperties()[18].PropertyType)
returns false!
left side:
typeof(IQueryable<>).MakeGenericType(typeof(T))
returns in watch:
{Name = "IQueryable`1" FullName = "System.Linq.IQueryable`1[[Domain.Groep, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"} System.Type {System.RuntimeType}
right side:
this.ObjectContext.GetType().GetProperties()[18].PropertyType
returns in watch:
{Name = "ObjectSet`1" FullName = "System.Data.Objects.ObjectSet`1[[Contacts.Groep, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"} System.Type {System.RuntimeType}
In english?
Why aren't ObjectSet and IQueryable assignable to one another for some entities in my EDMX?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有第二个 EDMX,其中包含一个 groep 实体,它导致了所有这些麻烦。
简单地删除重复的实体即可修复它-;)
I had a second EDMX that contained a groep entity, wich was causing all this trouble.
Simple removing the duplicate entitiy fixed it-;)