除了“常规”之外,我如何访问其他内容? T4 中 EntityModel 的 Entity-Property 的属性?
我使用以下代码来获取实体的所有属性
IList<EdmProperty> list = entity.Properties.Where(p => p.TypeUsage.EdmType is PrimitiveType && p.DeclaringType == entity)
然后我迭代这些列表,访问每个属性并读取属性属性(是的,很多属性,希望没有人感到困惑)。
虽然我可以轻松访问 General
属性,但我不知道如何访问实体属性的其他属性,例如 Max Length
& 固定长度
I am using sort of the following code to get all properties of a entity
IList<EdmProperty> list = entity.Properties.Where(p => p.TypeUsage.EdmType is PrimitiveType && p.DeclaringType == entity)
Then I iterate through these list, access each Property and read the Property Properties (Yeah, much properties, hope no one gets to confused).
While I can easily access the General
attributes I don't know how to access the other Properties of the the Entity-Property like Max Length
& Fixed Length
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这些属性不是
PrimitiveType
的一部分。它们直接位于Facets
属性下的p.TypeUsage
中。Those properties are not part of
PrimitiveType
. They are directly inp.TypeUsage
underFacets
property.尝试以下代码:
您可以在模板代码中使用 maxLength 变量。可以以类似的方式访问任何其他方面。
Try the following code:
You can use the maxLength variable in the template code. Any other facet can be accessed in a similar way.