Reputation: 107
Given an Entity Type, how to discover the ConcurrencyMode of a Property of that Entity Type at runtime by introspecting the MetadataWorkspace of CSpace? Thank you.
Upvotes: 1
Views: 594
Reputation: 3915
You can use TypeUsage.Facets
[EntityContext] etContext = new [EntityContext]();
var csdl = etContext.MetadataWorkspace.GetItemCollection(DataSpace.CSpace);
var entity = csdl.GetItems<EntityType>().Where(e => e.Name = [EntityType]).SingleOrDefault();
var edmProperty = entity.Properties.Where(p => p.Name == [PropertyName]).SingleOrDefault();
var mode = edmProperty.TypeUsage.Facets.Where(f => f.Name == "ConcurrencyMode").SingleOrDefault();
Upvotes: 1