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

发布于 2024-12-05 00:18:12 字数 114 浏览 3 评论 0原文

如果我有某个属性的 PropertyInfo 或该属性的 MVC 元数据,如何检测它是否具有 EF CodeFirst 中的 [NotMapped] 注释?谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓬勃野心 2024-12-12 00:18:12

你可以这样实现:

youPropertyInfo.GetCustomAttributes(typeof(NotMappedAttribute), true).Count() > 1

You can achive it like that:

youPropertyInfo.GetCustomAttributes(typeof(NotMappedAttribute), true).Count() > 1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文