Page 1 of 1

Auto set field MaxLength facet on creation

Posted: Mon 25 Jan 2010 14:48
by stephen.Cognito
Hi

Is it possible to have a setting to auto set the MaxLength facet of the table field (namely string type) on creation of the entity when creation is from an existing database. I see the option is there to set the property field by field for each table manually but on a large schema that is constantly evolving this is very time consuming.
I use the following code to get this value from the entity model...

ObjectStateEntry os = Entity.ObjectStateManager.GetObjectStateEntry(Table);
object value = os.EntitySet.ElementType.Members["Description"].TypeUsage.Facets["MaxLength"].Value;

I am looking to use this functionality for a validation class that will auto set the max edit length of an edit control from the entity string field thats assigned to it.

Thank you
Stephen

Posted: Tue 26 Jan 2010 14:33
by AndreyR
We have already implemented the MaxLength facet value setting.
Are the MaxLength facets set correctly
for both storage and conceptual properties of the varchar field? Please point out where the error is.