Closed maboivin closed 3 years ago
So Tenant -> Buildings -> Builder -> City works but not City -> Builder -> City. It could be a bug.
Your test will work if you set up your configuration as follows:
AutoMapper.IConfigurationProvider configurationProvider = new MapperConfiguration(cfg =>
{
cfg.AddMaps(typeof(Program).Assembly);
cfg.Advanced.RecursiveQueriesMaxDepth = 1;
});
IMapper mapper = new Mapper(configurationProvider);
Or in AutoMapper.v11:
AutoMapper.IConfigurationProvider configurationProvider = new MapperConfiguration(cfg =>
{
cfg.AddMaps(typeof(Program).Assembly);
cfg.Internal().RecursiveQueriesMaxDepth = 1;
});
IMapper mapper = new Mapper(configurationProvider);
RecursiveQueriesMaxDepth
is the number of times you want an already existing object to be included in the object graph.
AutoMapper takes an opt-in approach to configurations affecting performance. RecursiveQueriesMaxDepth
is not documented i.e. its use is discouraged.
Hi, I'm trying to expand a child collection and from that child collection, expand a parent. It works with EF Core and
EnableQuery
out of the box but the expansion of the last parent seems to be ignored by AutoMapper (using AutoMapper.Extensions.OData v2.2.0-preview.1).I was also able to reproduce the issue with the AutoMapper.OData.EFCore.Tests.
First, I added a simple child collection property to the TCity entity.
Then, I did the same for the OpsCity entity.
Then. I added a unit test in GetQueryTests.
I expected that the City property would have been loaded.
Now, I was able to reproduce the issue with the WebAPI.OData.EFCore project as well.
I added an OData controller to query the OpsCity entity set.
When querying
http://localhost:16324/opscity?$expand=builders($expand=city)
, it returns the following data:using the following SQL query:
Then, I added the TCity and TBuilder entites to the OData model and an OData controller to query the TCity entity set directly from EF Core using the
EnableQuery
attribute.When querying
http://localhost:16324/tcity?$expand=builders($expand=city)
, it returns the following data:using the following SQL query:
My first thought is that I think AutoMapper should return the City as well. Is there a setting or a configuration that needs to be changed? Or is it possible that it's a bug when translating the expand clause into the select expression?