我可以在局部类定义属性,然后将它们标记与另一部分类的属性? [英] Can I define properties in partial classes, then mark them with attributes in another partial class?
问题描述
有没有方法可以让我有一个生成的code,像这样的文件:
Is there a way I can have a generated code file like so:
public partial class A {
public string a {get; set;}
}
然后在另一个文件中:
and then in another file:
public partial class A {
[Attribute("etc")]
public string a {get; set;}
}
所以,我可以从数据库中生成的类,然后使用非生成的文件将其标记?
So that I can have a class generated from the database and then use a non-generated file to mark it up?
推荐答案
我见过这样的事情由Scott Guthrie的文章中做了(靠近它的结束) - 不自己试试吧,虽然
<一href=\"http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx\">http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx
I've seen something like this done in an article by Scott Guthrie (near the end of it) - didn't try it myself, though.
http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx
这篇关于我可以在局部类定义属性,然后将它们标记与另一部分类的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!