如何从EdmProperty中检索EF POCO属性显示值

时间:2014-12-17 11:48:07

标签: c# entity-framework

我有一个已翻译的应用程序,我的POCO中的所有属性都标记为

[Display(ResourceType = typeof(Resources), Name = "Name")]
public string Name { get; set; }

在运行时,我想反思属性并获取它的资源值,就像这样。

EdmProperty prop = entityType.Properties.SingleOrDefault(x => x.Name.Equals("Name", StringComparison.CurrentCultureIgnoreCase));

此时我希望能够从这个EdmProperty中获取Name注释,以及那些被困的地方。我试着查看EdmProperty的源文件,但我似乎无法找到答案。

1 个答案:

答案 0 :(得分:0)

试试这段代码

if(prop.Documentation != null && !prop.Documentation.IsEmpty)
{
   var displayName = prop.Documentation.Summary;
} 
相关问题