type.getProperties收集和偶像之间的不同属性
我正在尝试构建一个表达式树,
var param = Expression.Parameter(typeof(T), "Foo");
var property = Expression.Property(param, "Bar");
var param2 = Expression.Parameter(property.Type.GetProperty("Item").PropertyType, "x");
现在有此代码,bar是foo的集合属性,我声明它,因为
public Collection<Bar> Bar {get;set;}
我可以在调用type.getProperty后获得项目属性。
我现在面临的问题是实体类是自动化的,并将其称为
public ICollection<Bar> Bar {get;set;}
即使使用接口(例如Icollection),因为我无法更改类的属性类型,即使使用接口(例如Icollection)也有办法获取。任何帮助都将受到赞赏。
I am try to build an expression tree and I have this code
var param = Expression.Parameter(typeof(T), "Foo");
var property = Expression.Property(param, "Bar");
var param2 = Expression.Parameter(property.Type.GetProperty("Item").PropertyType, "x");
Now, Bar is a Collection property of Foo and I declare it as
public Collection<Bar> Bar {get;set;}
I am able to get the Item property once I call the Type.GetProperty
The problem I'm facing now is that the Entity class is autogenerated and it is declared as
public ICollection<Bar> Bar {get;set;}
Once I call the Type.GetProperty on ICollection, the Item property is missing.
Is there a way to get that even when using Interface (e.g. ICollection) since I cannot change the type of the properties of the class. Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我现在明白了。
我只需要转换属性类型,以便可以访问该属性。
Ok I got it now.
I just need to convert the property type so I can access that property.