Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StringLength without maximum limit

I want to use String length data annotation in my asp.net MVC3 model class. I see that I must give the maximumlength. Cant I just give the Minimumlength to make sure that there are atleaset 5 characters entered ?

[StringLength(10, MinimumLength = 5)]

Please suggest.

like image 630
DotnetSparrow Avatar asked Mar 20 '26 04:03

DotnetSparrow


1 Answers

A standard maximum length for a string in Entity Framework is 4000. That is reasonably long, but if it doesn't suit your needs you could always set the maximum length to the size of the corresponding column in the database.

If your really don't care, another option is using int.MaxValue as de maximum length.

like image 149
Sergi Papaseit Avatar answered Mar 21 '26 20:03

Sergi Papaseit