Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect a [NotMapped] annotation from PropertyInfo or MetaData?

If I have the PropertyInfo for a property or the MVC MetaData for that property, how can I detect whether it has the [NotMapped] annotation from EF CodeFirst? Thanks.

like image 627
Benjamin Avatar asked Sep 16 '11 14:09

Benjamin


1 Answers

You can achive it like that:

youPropertyInfo.GetCustomAttributes(typeof(NotMappedAttribute), true).Count() > 1
like image 124
Dirk von Grünigen Avatar answered Nov 15 '22 11:11

Dirk von Grünigen