Skip to content

Restructure ODataMetadata to mirror XML Schema hierarchy#45

Draft
Copilot wants to merge 5 commits intomasterfrom
copilot/add-odata-service-list
Draft

Restructure ODataMetadata to mirror XML Schema hierarchy#45
Copilot wants to merge 5 commits intomasterfrom
copilot/add-odata-service-list

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

ODataEntityContainer was renamed to ODataSchema but still only held EntityContainer-level data. The ODataMetadata root object held flat aggregated lists that didn't reflect the actual <Schema><EntityContainer> nesting in OData $metadata XML.

Structural changes

  • ODataMetadata stripped to two fields only:
    public class ODataMetadata {
        public ODataVersion ODataVersion { get; set; }
        public List<ODataSchema> Schemas { get; set; } = [];
    }
  • ODataSchema now owns everything declared within a <Schema> element:
    public class ODataSchema {
        public string Namespace { get; set; }       // <Schema Namespace="...">
        public string? ContainerName { get; set; }  // <EntityContainer Name="...">
        public List<ODataEntityType> EntityTypes { get; set; }
        public List<ODataEnumType> EnumTypes { get; set; }
        public List<ODataEntitySet> EntitySets { get; set; }
        public List<ODataSingleton> Singletons { get; set; }
        public List<ODataFunction> Functions { get; set; }
    }
  • Helper methods (GetDerivedTypes, GetAllDerivedTypes, SetEntityPaths) moved from ODataMetadata to ODataSchema. SetEntityPaths accepts a cross-schema entity type list to support multi-schema V4 documents; internally uses a pre-built lookup dict (O(n) vs prior O(n²)).

Parser changes

  • V4 parser: creates one ODataSchema per XML <Schema> element; EntitySets/Singletons/Functions are populated only on the schema that owns the <EntityContainer>.
  • V1/V3 parser: creates a single ODataSchema from the one XML schema element.
  • MarkEnumProperties updated in both parsers to operate per-schema or across all schemas as appropriate.

Consumer updates

  • ClientGenerator, ClientTemp, ClientHelperTemplate, MetadataExtensions: iterate metadata.Schemas instead of flat metadata.EntityTypes / metadata.Functions etc.
  • Blazor doc components (GenerateClient.razor, ODataExplorer.razor): use SelectMany across schemas for aggregated display.
  • MetadataTests: single-schema tests use metadata.Schemas[0].X; complex multi-schema V4 tests use per-schema access or metadata.Schemas.SelectMany(s => s.X).

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: joadan <8363110+joadan@users.noreply.github.com>
Copilot AI changed the title [WIP] Introduce List of ODataService in ODataMetadata Add ODataEntityContainer list to ODataMetadata to reflect XML structure Feb 27, 2026
Co-authored-by: joadan <8363110+joadan@users.noreply.github.com>
Copilot AI changed the title Add ODataEntityContainer list to ODataMetadata to reflect XML structure Add ODataEntityContainer list and Namespace to ODataMetadata Feb 27, 2026
… to ContainerName

Co-authored-by: joadan <8363110+joadan@users.noreply.github.com>
Copilot AI changed the title Add ODataEntityContainer list and Namespace to ODataMetadata Rename ODataEntityContainer to ODataSchema; add Namespace property Feb 27, 2026
Copy link
Owner

@joadan joadan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to match the XML structure we should move types, enums etc to the new ODataSchema

…as ODataVersion + Schemas

Co-authored-by: joadan <8363110+joadan@users.noreply.github.com>
Copilot AI changed the title Rename ODataEntityContainer to ODataSchema; add Namespace property Restructure ODataMetadata to mirror XML Schema hierarchy Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants