Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FromDynamic on TaxonomyElement produces RuntimeBinderException on Value #265

Open
kylejuliandev opened this issue Apr 23, 2024 · 1 comment

Comments

@kylejuliandev
Copy link

Description

Accessing the Value IEnumerable produces a RuntimeBinderException.

using Kontent.Ai.Management.Models.LanguageVariants.Elements;
using Kontent.Ai.Management.Models.Shared;
using Kontent.Ai.Management.Models.Types.Elements;

var taxonomy = new TaxonomyElement
{
    Element = Reference.ByCodename("my_taxonomy"),
    Value = [Reference.ByCodename("my_taxonomy_item_1")]
};

var taxonomy2 = (TaxonomyElement) TaxonomyElement.FromDynamic(taxonomy.ToDynamic(), ElementMetadataType.Taxonomy);

var value1 = taxonomy2.Value.First();

Exception message: 'Kontent.Ai.Management.Models.Shared.Reference' does not contain a definition for 'id'

Stack trace

at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at Kontent.Ai.Management.Models.LanguageVariants.Elements.BaseElement.<>c.<FromDynamic>b__6_5(Object identifier)
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at Program.<Main>$(String[] args) in D:\repos\demo\KontentAiMigrationAssistant\KontentAiMigrationAssistant\Program.cs:line 42

I also tried with Reference.ById and Reference.ByExternalId for the Value item and all produced the same exception.

Test environment

  • Platform/OS: .NET 8.0
  • Version: 6.0.0
@pokornyd
Copy link
Member

hello and thanks for the submission, as well as the draft PR. I'll review the issue and the proposed changes but feel free to add further improvements before marking the PR for review.

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 a pull request may close this issue.

2 participants