简体   繁体   English

如何在Sharp架构中使用数据注释

[英]How to use Data Annotations with Sharp Architecture

We recently upgraded to MVC2 and SharpArchitecture 1.6. 我们最近升级到了MVC2和SharpArchitecture 1.6。 Our models are all in our Project.Core project, while resources are in our Project.Web project. 我们的模型全部在Project.Core项目中,而资源在Project.Web项目中。 We can't reference the resource files in Core , as that would create a circular dependency. 我们不能在Core中引用资源文件,因为那样会创建循环依赖。

We want to use Data Annotations on the model - is there a way to access the resource files so we can have localized messages? 我们想在模型上使用数据注释-是否有访问资源文件的方法,以便我们可以本地化消息?

Why not extract in a stand alone project all your resources? 为什么不从一个独立的项目中提取所有资源呢? you can then reference them from every project without the circular reference. 然后,您可以从每个项目中引用它们,而无需循环引用。 From dataannotaion you link them like this 从dataannotaion,您可以像这样链接它们

[Required(ErrorMessageResourceType = typeof(Resources.Validations), ErrorMessageResourceName = "Required")]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM