T4 访问具有特定注解的属性列表

T4 access list of properties with a certain annotation

使用 [key] 注释访问 t4 文件属性,例如在 ownedAttributes 和 navigableOwnedEnds 中

这是我一直在寻找的答案

foreach(IProperty attribute in this.Element.OwnedAttributes)
{
  string attributeList = GetProperty(attribute, "property", "ClrAttributes");
  if(!string.IsNullOrEmpty(attributeList))
  {
    //attributeList now will contain the attribute put in 
    //Streotypes>C# property>ClrAttributes
  }
}