Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Textbox.maxlength value in winforms from Entity Framework model

$
0
0

In our project we've many TextBox controls bounded to the database (Business Object Data Source). We use Entity Framework Code first with additional attributes in metadata to create database business objects:

[MetadataType(typeof(OsobyMetadata))]publicclassOsoby{publicOsoby(){this.Pracownicy=newList<Pracownicy>();}publicintId_Os{get;set;}publicstringNazwisko{get;set;}publicstringNazwiskoRodowe{get;set;}publicstringImie{get;set;}publicstringDrugieImie{get;set;}publicstringPlec{get;set;}publicDateTime?DataUrodzenia{get;set;}publicstringMiejsceUrodzenia{get;set;}publicstringPesel{get;set;}publicvirtualICollection<Pracownicy>Pracownicy{get;set;}}

(...)

publicclassOsobyMetadata{[MaxLength(50),Required]publicstringNazwisko{get;set;}[MaxLength(50),Required]publicstringImie{get;set;}[MaxLength(20)]publicstringPesel{get;set;}}

Each column in the database have set correct column maxlength value (ex. nvarchar(50)) but there's a problem with textbox controls on GUI. We've to set manually maxlength attribute of each textbox control and make sure that values on GUI and DB are correlated.

We're trying to automatically match the maxlength of each textbox to the same value as the database column. What's the best way to do that?


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>