Created
February 26, 2016 11:58
-
-
Save testfirstcoder/44a79bd606269a4874de to your computer and use it in GitHub Desktop.
Get value from DataAnnotations.StringLengthAttribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int GetStringLengthAttributeValue<T>(string property) | |
{ | |
return typeof(T) | |
.GetProperty(property) | |
.GetCustomAttribute<StringLengthAttribute>() | |
.MaximumLength; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment