ViewData.Model = new AdministrativeDivision();
var properties = ViewData.ModelMetadata.Properties;
var t1 = properties.Where(e => e.PropertyName == "AdministrativeDivisionName").FirstOrDefault();
t1.DisplayName = "卧槽";
public virtual IEnumerable<ModelMetadata> Properties { get { if (_properties == null) { IEnumerable<ModelMetadata> originalProperties = Provider.GetMetadataForProperties(Model, RealModelType); // This will be returned as a copied out array in the common case, so reuse the returned array for performance. _propertiesInternal = SortProperties(originalProperties.AsArray()); _properties = new ReadOnlyCollection<ModelMetadata>(_propertiesInternal); } return _properties; } }
它是只读的
ModelMetadataProviders.Current = new MyMetadataProvider("Name", true);
通过自定义已经实现功能,但是如果遇到并发可能有问题。。。