views:

40

answers:

0

Hi everyone,

I'm currently working with Entities (using visual studio 2008, FW 3.5 SP1). I created my entities from the database, and everything is ok, except that my lenght constraints on the string fields are not enforced. Browsing the internet, I found out that this is quite normal (see this blog post), and that Entities sends the data without check to the database, to possibly send exceptions.

I know I could write partial classes for my entities, and use the On<Fieldname>Changing methods, but this would require quite an amount of repetitive code to be written. Moreover if I change a lenght in the DB, this would require me to change my code aswell.

So my question is: Is there a generic way to to this ? Is it possible, for each data type which has a maximum length to check if the provided value is fitting ?

Thanks in advance !