Skip to content

Instantly share code, notes, and snippets.

@bzbetty
Created November 15, 2012 09:21
Show Gist options
  • Save bzbetty/4077594 to your computer and use it in GitHub Desktop.
Save bzbetty/4077594 to your computer and use it in GitHub Desktop.
public class MetadataProvider : DataAnnotationsModelMetadataProvider
{
private IConfigurationProvider _mapper;
public MetadataProvider(IConfigurationProvider mapper)
{
_mapper = mapper;
}
protected override System.Web.Mvc.ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName)
{
//Grab attributes from the entity columns and copy them to the view model
var mappedAttributes = _mapper.GetMappedAttributes(containerType, propertyName, attributes);
return base.CreateMetadata(mappedAttributes, containerType, modelAccessor, modelType, propertyName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment