kontent-ai / model-generator-net

Kontent.ai .NET model generator.
https://www.nuget.org/packages/Kontent.Ai.ModelGenerator
MIT License
17 stars 19 forks source link

Known types - LI element limited to multiple types with at least 1 item #161

Open Sevitas opened 1 year ago

Sevitas commented 1 year ago

Motivation

Solves scenario 4 of issue #90 scenarios Linked items element limited to multiple types with at least 1 item.

Proposed solution

Article.Generated.cs will contain

public IEnumerable<IContentItem> Sections { get; set; }

Article.Typed.Generated.cs will contain

public IEnumerable<Banner> SectionsBannerTyped => Sections.OfType<Banner>();
public IEnumerable<CompanyNews> SectionsCompanyNewsTyped => Sections.OfType<CompanyNews>();

Additional context

As a developer, you still need to check which properties contain any items. Some properties might be empty. Take in mind responses and notes in the comment.