我有一个在其中定义了[DataContract]类的WCF服务。每个属性都有[DataMember]属性,并且我向一些属性添加了一些Data Annotation属性[必需的]和[StringLength]。WCF服务合同上的数据注释
然后我在asp.net MVC应用程序中使用此服务作为服务引用。当我得到所有使用属性的列表时
var attr= from prop in TypeDescriptor.GetProperties(instance).Cast<PropertyDescriptor>()
from attribute in prop.Attributes.OfType<ValidationAttribute>()
select attribute;
我看不到任何数据注释已经通过。这是WCF的限制还是我在这里做了一些根本性的错误?
所以底线,有没有什么办法可以让IDE复制DataAnnotations属性给消费者代理类?如果是,如何?我没有找到您的文章中提到的'使用现有类型'选项(我使用VS10)。 – Shimmy 2011-02-13 08:20:33