I've been creating a nice T4 template for a repository pattern for my entities. Instead of manually parsing the xml in the edmx file I use the EdmItemCollection to create a object graph presentation for the conceptual model.
I've been able to get a lot of information out of this model. But I cant find where to locate the Getter and Setter access modifiers. They are present in the CSDL part of the edmx file.
Example:
<Property Name="CustomerID" Type="String" Nullable="false" MaxLength="5" Unicode="true" FixedLength="true"
a:SetterAccess="Public" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
Where in the object graph should I look for this information?
Here is an example of how I parse the object tree.
EdmItemCollection edmItems = new EdmItemCollection(new XmlReader[] { csdlReader });
var ownEntities = from item in edmItems
where item.BuiltInTypeKind == BuiltInTypeKind.EntityType
select item as EntityTypeBase;
Entities = (from ent in ownEntities // Entities is a property, therefore no declaration
select new Entity
{
Name = ent.Name,
SetName = (from entSet in entityContainer.BaseEntitySets
where (entSet.ElementType == ent) || (ent.BaseType != null && (entSet.ElementType.FullName.Equals(ent.BaseType.FullName)))
select entSet.Name).FirstOrDefault(),
Keys = (from keys in ent.KeyMembers
select new Entity.Member
{
Name = keys.Name,
Type = keys.TypeUsage.EdmType.Name
}).ToList(),
Properties = (from prop in ent.Members
select new Entity.Member
{
Name = prop.Name,
Type = prop.TypeUsage.EdmType.Name,
IsCollection = prop.TypeUsage.EdmType.BuiltInTypeKind == BuiltInTypeKind.CollectionType
}).ToList()
}).ToList();
I hope it's clear in which direction I'm going.
After a lot of reflectoring trough the code of the EdmItemCollection that it doesn't load the http://schemas.microsoft.com/ado/2006/04/codegeneration schema, so it just ignores those properties.
But I'm hoping somebody can help me find out how to locate this information?