I need to do some trimming before saving various fields in our database. We\'re deserializing xml from another application into EF entities and then inserting them. There ar
You can find the properties by this piece of code:
var varchars = context.MetadataWorkspace.GetItemCollection(DataSpace.CSpace)
.Where(gi => gi.BuiltInTypeKind == BuiltInTypeKind.EntityType)
.Cast<EntityType>()
.SelectMany(entityType => entityType.Properties
.Where(edmProperty => edmProperty.TypeUsage.EdmType.Name == "String")
.Where(edmProperty => (int)(edmProperty.TypeUsage.Facets["MaxLength"]
.Value) >= 4000))
.ToList();
The trick is to extract the entity types from the model by BuiltInTypeKind.EntityType
and cast these to EntityType
to get access to the Properties
. An EdmProperty has a property DeclaringType
which shows to which entity they belong.