Here is how to get the primary key of an entitySetName
var primaryKeyName = objDb
.MetadataWorkspace
.GetEntityContainer(objDb.DefaultContainerName, System.Data.Metadata.Edm.DataSpace.CSpace)
.BaseEntitySets
.First(meta => meta.ElementType.Name == entitySetName)
.ElementType
.KeyMembers
.Select(k => k.Name)
.FirstOrDefault();
var primaryKeyName = objDb
.MetadataWorkspace
.GetEntityContainer(objDb.DefaultContainerName, System.Data.Metadata.Edm.DataSpace.CSpace)
.BaseEntitySets
.First(meta => meta.ElementType.Name == entitySetName)
.ElementType
.KeyMembers
.Select(k => k.Name)
.FirstOrDefault();
No comments:
Post a Comment