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

Property of type Enum List fails to Map/Convert #18128

Closed
mreyeros opened this issue Sep 29, 2019 · 3 comments
Closed

Property of type Enum List fails to Map/Convert #18128

mreyeros opened this issue Sep 29, 2019 · 3 comments

Comments

@mreyeros
Copy link

mreyeros commented Sep 29, 2019

The following simple model fails to map when querying with the Azure Cosmos Db provider:

public class FulfillmentOptionConfig {
        public string Id { get; set; }
        public FulfillmentOption FulfillmentOption { get; set; }
        public List<Peril> AllowedPerils { get; set; } = new List<Peril>();
        public string DocumentType { get; set; } = Constants.DocumentTypes.FulfillmentOptionConfig;
    }

I have attempted to convert the property using a ValueConverter but the following error is encountered:

Error: System.ArgumentException: Can not convert Array to String.
at Newtonsoft.Json.Linq.JToken.op_Explicit(JToken value)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObjectT
at lambda_method(Closure , QueryContext , JObject )
at Microsoft.EntityFrameworkCore.Cosmos.Query.Internal.CosmosShapedQueryCompilingExpressionVisitor.AsyncQueryingEnumerable1.AsyncEnumerator.MoveNextAsync() at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at DF.ConfigManager.Features.Configuration.FulfillmentOptions.IndexMediator.QueryHandler.Handle(Query request, CancellationToken cancellationToken) in C:\dev\DF.ConfigManager\src\DF.ConfigManager\Features\Configuration\FulfillmentOptions\IndexMediator.cs:line 27 at MediatR.Pipeline.RequestPostProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) at MediatR.Pipeline.RequestPreProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at DF.ConfigManager.Features.Configuration.FulfillmentOptions.IndexBase.OnInitializedAsync() in C:\dev\DF.ConfigManager\src\DF.ConfigManager\Features\Configuration\FulfillmentOptions\Index.razor.cs:line 18
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

If the property is ignored, the model is returned successfully. I have another property, FulfillmentOption, which is of type enum and is setup to use the EnumToStringConverter and that is working without issue.

EF Core version: 3.0.0
Database provider: Microsoft.EntityFrameworkCore.Cosmos
Target framework: .NET Core 3.0
Operating system: Windows 10
IDE: Visual Studio 2019 16.3

@AndriySvyryd
Copy link
Member

Duplicate of #14762

@ggirard07
Copy link

This issue has been closed as duplicate of #14762, but that one address primitive types like string or int but does not seem to support enum.
@AndriySvyryd is it possible to reopen?

@AndriySvyryd
Copy link
Member

The new duplicate is #25343

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants