如何从PropertyInfo或MetaData中检测[NotMapped]注释?

Ben*_*min 4 reflection asp.net-mvc entity-framework-4 ef-code-first entity-framework-4.1

如果我拥有该PropertyInfo属性的属性或MVC MetaData,我如何检测它是否具有[NotMapped]EF CodeFirst 的注释?谢谢.

Dir*_*gen 7

你可以这样做:

youPropertyInfo.GetCustomAttributes(typeof(NotMappedAttribute), true).Count() > 1
Run Code Online (Sandbox Code Playgroud)