Bart Strubbe
Bart Strubbe

Reputation: 107

Entity Framework, get ConcurrencyMode of Properties from MetadataWorkspace, how?

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

Answers (1)

Raj Ranjhan
Raj Ranjhan

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

Related Questions