DotnetSparrow
DotnetSparrow

Reputation: 27996

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.

Upvotes: 3

Views: 626

Answers (1)

Sergi Papaseit
Sergi Papaseit

Reputation: 16194

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.

Upvotes: 1

Related Questions