Skip to content

DefaultExpansionsBuilder does not support dictionaries #239

@amorelIM

Description

@amorelIM

Hi @BlaiseD,

I tried to upgrade from version 5.0.2 to 7.0.1, and I have an issue since the DefaultExpansionsBuilder was added. I have the following entities :

// EFCore entity
class Entity
{
  public Guid Id {get; set;}

  public string ExtraData {get; set;} // JSON stored as string
}

// OData entity
class EntityDto
{
  public Guid Id {get; set;}

  public IDictionary<string, string> ExtraData {get; set;} = new Dictionary<string, string>(); // It's a dictionary of strings since we don't know what's stored in the JSON.
}

But now at runtime a get the following exception because the dictionary contains 2 generics.

System.ArgumentException: type
   at LogicBuilder.Expressions.Utils.TypeExtensions.GetUnderlyingElementType(Type type)
   at AutoMapper.AspNet.OData.Expansions.DefaultExpansionsBuilder.Build(List`1 memberSelectors, ParameterExpression param, Expression parentBody)
   at AutoMapper.AspNet.OData.Expansions.DefaultExpansionsBuilder.Build(ParameterExpression param, Expression parentBody)
   at AutoMapper.AspNet.OData.Expansions.ExpansionsHelper.GetSelectedSelectors(ParameterExpression param, Expression parentBody, List`1 selects)
   at AutoMapper.AspNet.OData.Expansions.ExpansionsHelper.AddSelectors(List`1 memberSelectors, List`1 selects, ParameterExpression param, Expression parentBody)
   at AutoMapper.AspNet.OData.Expansions.ExpansionsHelper.<>c__DisplayClass2_0`1.<BuildExplicitExpansions>g__GetAllExpansions|0(List`1 memberSelectors)
   at AutoMapper.AspNet.OData.Expansions.ExpansionsHelper.BuildExplicitExpansions[TSource](IEnumerable`1 includes, List`1 selects)
   at AutoMapper.AspNet.OData.QueryableExtensions.GetQueryable[TModel,TData](IQueryable`1 query, IMapper mapper, ODataQueryOptions`1 options, QuerySettings querySettings, Expression`1 filter)
   at AutoMapper.AspNet.OData.QueryableExtensions.GetQueryAsync[TModel,TData](IQueryable`1 query, IMapper mapper, ODataQueryOptions`1 options, QuerySettings querySettings)

I don't mind doing the correction, but I would need some guidance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions