Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 93157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:18:01+00:00 2026-05-10T23:18:01+00:00

I’ve been creating a nice T4 template for a repository pattern for my entities.

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:18:02+00:00Added an answer on May 10, 2026 at 11:18 pm

    Thanks to Noam Ben-Ami from Microsoft who pointed me to the blog post Annotations in CSDL I’m able to answered my own question.

    Everything which is not directly presented in the Object Model from the Edm types can still be found in the MetadataProperties (which contains every xml property of the element, even the ones which are represented as typed properties).

    I just have to look for a MetadataProperty which name begins with ‘http://schemas.microsoft.com/ado/2006/04/codegeneration:’ and I’ve found it.

    To answer my code example:

    String codeGenerationXmlns = 'http://schemas.microsoft.com/ado/2006/04/codegeneration'; EdmItemCollection edmItems = new EdmItemCollection(new XmlReader[] { csdlReader }); var ownEntities = from item in edmItems                   where item.BuiltInTypeKind == BuiltInTypeKind.EntityType                   select item as EntityTypeBase; var entityContainer = (from item in edmItems                        where item.BuiltInTypeKind == BuiltInTypeKind.EntityContainer                        select item as EntityContainer).FirstOrDefault(); Entities = (from ent in ownEntities             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(),                 IsPublic = ((from metaProps in ent.MetadataProperties                              where metaProps.Name.Equals(codeGenerationXmlns + ':TypeAccess')                              select metaProps.Value).FirstOrDefault() ?? 'Public').Equals('Public'),                 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,                                   PrivateGetter = ((from metaProps in prop.MetadataProperties                                                     where metaProps.Name.Equals(codeGenerationXmlns + ':GetterAccess')                                                     select metaProps.Value).FirstOrDefault() ?? 'Public').Equals('Private'),                                   PrivateSetter = ((from metaProps in prop.MetadataProperties                                                     where metaProps.Name.Equals(codeGenerationXmlns + ':SetterAccess')                                                     select metaProps.Value).FirstOrDefault() ?? 'Public').Equals('Private'),                               }).ToList()             }).ToList(); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 71k
  • Answers 71k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Making it const and making it static do two different… May 11, 2026 at 1:09 pm
  • added an answer An instance of HashMap<String, String> matches Map<String, ?> but not… May 11, 2026 at 1:09 pm
  • added an answer You probably need to set the base url. For example:… May 11, 2026 at 1:09 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.