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

Fix for Issue #194: FindSortableProperties - The type '{type.FullName… #226

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ IEdmEntityType GetEntity()
if (entities.Count == 1)
return entities[0];

if (entities.Count > 1)
{
return entities.SingleOrDefault(e => GetClrType(e, context.Model).FullName == type.FullName);
}

return null;
}

static Type GetClrType(IEdmEntityType entityType, IEdmModel edmModel)
=> TypeExtensions.GetClrType(new EdmEntityTypeReference(entityType, true), edmModel, TypeExtensions.GetEdmToClrTypeMappings());

static OrderBySetting FindProperties(IEdmEntityType entity, OrderByDirection orderByDirection)
{
var propertyNames = entity.Key().Any() switch
Expand Down
10 changes: 5 additions & 5 deletions AutoMapper.OData.EF6.Tests/GetQuerySelectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void Initialize()
}

[Fact]
public async void OpsTenantSelectNameExpandBuildings()
public async Task OpsTenantSelectNameExpandBuildings()
{
string query = "/opstenant?$select=Name&$expand=Buildings&$orderby=Name";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -62,7 +62,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void OpsTenantExpandBuildingsFilterEqAndOrderBy_FirstBuildingHasValues()
public async Task OpsTenantExpandBuildingsFilterEqAndOrderBy_FirstBuildingHasValues()
{
string query = "/opstenant?$top=5&$select=Buildings&$expand=Buildings&$filter=Name eq 'One'&$orderby=Name desc";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -81,7 +81,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void BuildingSelectNameExpandBuilder_BuilderNameShouldBeSam()
public async Task BuildingSelectNameExpandBuilder_BuilderNameShouldBeSam()
{
string query = "/corebuilding?$top=5&$select=Name&$expand=Builder($select=Name)&$filter=Name eq 'One L1'";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -100,7 +100,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderSelectNamefilterEqAndOrderBy()
public async Task BuildingExpandBuilderSelectNamefilterEqAndOrderBy()
{
string query = "/corebuilding?$top=5&$expand=Builder($select=Name)&$filter=Name eq 'One L1'";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -119,7 +119,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderSelectNameExpandCityFilterEqAndOrderBy_CityShouldBeExpanded_BuilderNameShouldBeSam_BuilderIdShouldBeZero()
public async Task BuildingExpandBuilderSelectNameExpandCityFilterEqAndOrderBy_CityShouldBeExpanded_BuilderNameShouldBeSam_BuilderIdShouldBeZero()
{
string query = "/corebuilding?$top=5&$expand=Builder($select=Name;$expand=City)&$filter=Name eq 'One L1'";
Test(Get<CoreBuilding, TBuilding>(query));
Expand Down
106 changes: 53 additions & 53 deletions AutoMapper.OData.EF6.Tests/GetQueryTests.cs

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions AutoMapper.OData.EF6.Tests/GetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void Initialize()
}

[Fact]
public async void OpsTenantExpandBuildingsFilterEqAndOrderBy()
public async Task OpsTenantExpandBuildingsFilterEqAndOrderBy()
{
string query = "/opstenant?$top=5&$expand=Buildings&$filter=Name eq 'One'&$orderby=Name desc";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -70,7 +70,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void OpsTenantExpandBuildingsFilterNeAndOrderBy()
public async Task OpsTenantExpandBuildingsFilterNeAndOrderBy()
{
string query = "/opstenant?$top=5&$expand=Buildings&$filter=Name ne 'One'&$orderby=Name desc";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -86,7 +86,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void OpsTenantFilterEqNoExpand()
public async Task OpsTenantFilterEqNoExpand()
{
string query = "/opstenant?$filter=Name eq 'One'";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -102,7 +102,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void OpsTenantExpandBuildingsNoFilterAndOrderBy()
public async Task OpsTenantExpandBuildingsNoFilterAndOrderBy()
{
string query = "/opstenant?$top=5&$expand=Buildings&$orderby=Name desc";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -118,7 +118,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void OpsTenantNoExpandNoFilterAndOrderBy()
public async Task OpsTenantNoExpandNoFilterAndOrderBy()
{
string query = "/opstenant?$orderby=Name desc";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -134,7 +134,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void OpsTenantNoExpandFilterEqAndOrderBy()
public async Task OpsTenantNoExpandFilterEqAndOrderBy()
{
string query = "/opstenant?$top=5&$filter=Name eq 'One'&$orderby=Name desc";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -150,7 +150,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void OpsTenantExpandBuildingsExpandBuilderExpandCityFilterNeAndOrderBy()
public async Task OpsTenantExpandBuildingsExpandBuilderExpandCityFilterNeAndOrderBy()
{
string query = "/opstenant?$top=5&$expand=Buildings($expand=Builder($expand=City))&$filter=Name ne 'One'&$orderby=Name desc";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -168,7 +168,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void BuildingExpandBuilderTenantFilterEqAndOrderBy()
public async Task BuildingExpandBuilderTenantFilterEqAndOrderBy()
{
string query = "/corebuilding?$top=5&$expand=Builder,Tenant&$filter=Name eq 'One L1'";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -185,7 +185,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderTenantFilterOnNestedPropertyAndOrderBy()
public async Task BuildingExpandBuilderTenantFilterOnNestedPropertyAndOrderBy()
{
string query = "/corebuilding?$top=5&$expand=Builder,Tenant&$filter=Builder/Name eq 'Sam'&$orderby=Name asc";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -202,7 +202,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderTenantExpandCityFilterOnPropertyAndOrderBy()
public async Task BuildingExpandBuilderTenantExpandCityFilterOnPropertyAndOrderBy()
{
string query = "/corebuilding?$top=5&$expand=Builder($expand=City),Tenant&$filter=Name ne 'One L2'&$orderby=Name desc";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -218,7 +218,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderTenantExpandCityFilterOnNestedNestedPropertyWithCount()
public async Task BuildingExpandBuilderTenantExpandCityFilterOnNestedNestedPropertyWithCount()
{
string query = "/corebuilding?$top=5&$expand=Builder($expand=City),Tenant&$filter=Builder/City/Name eq 'Leeds'&$count=true";
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
Expand Down Expand Up @@ -251,7 +251,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderTenantExpandCityOrderByName()
public async Task BuildingExpandBuilderTenantExpandCityOrderByName()
{
string query = "/corebuilding?$top=5&$expand=Builder($expand=City),Tenant&$orderby=Name desc";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -266,7 +266,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderTenantExpandCityOrderByNameThenByIdentity()
public async Task BuildingExpandBuilderTenantExpandCityOrderByNameThenByIdentity()
{
string query = "/corebuilding?$top=5&$expand=Builder($expand=City),Tenant&$orderby=Name desc,Identity";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -281,7 +281,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderName()
public async Task BuildingExpandBuilderTenantExpandCityOrderByBuilderName()
{
string query = "/corebuilding?$top=5&$expand=Builder($expand=City),Tenant&$orderby=Builder/Name";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -297,7 +297,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Take1WithCount()
public async Task BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Take1WithCount()
{
string query = "/corebuilding?$skip=4&$top=1&$expand=Builder($expand=City),Tenant&$orderby=Name desc,Identity&$count=true";
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
Expand All @@ -319,7 +319,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Take1NoCount()
public async Task BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Take1NoCount()
{
string query = "/corebuilding?$skip=4&$top=1&$expand=Builder($expand=City),Tenant&$orderby=Name desc,Identity";
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
Expand All @@ -342,7 +342,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingSelectNameWithoutOrderWithoutTop()
public async Task BuildingSelectNameWithoutOrderWithoutTop()
{
string query = "/corebuilding?$select=Name";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -356,7 +356,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingWithoutTopAndPageSize()
public async Task BuildingWithoutTopAndPageSize()
{
string query = "/corebuilding";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -370,7 +370,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingWithTopOnly()
public async Task BuildingWithTopOnly()
{
string query = "/corebuilding?$top=3";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -384,7 +384,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingWithPageSizeOnly()
public async Task BuildingWithPageSizeOnly()
{
string query = "/corebuilding";
var querySettings = new QuerySettings { ODataSettings = new ODataSettings { HandleNullPropagation = HandleNullPropagationOption.False, PageSize = 2 } };
Expand All @@ -399,7 +399,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingWithTopAndSmallerPageSize()
public async Task BuildingWithTopAndSmallerPageSize()
{
string query = "/corebuilding?$top=3";
var querySettings = new QuerySettings { ODataSettings = new ODataSettings { HandleNullPropagation = HandleNullPropagationOption.False, PageSize = 2 } };
Expand All @@ -414,7 +414,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingWithTopAndLargerPageSize()
public async Task BuildingWithTopAndLargerPageSize()
{
string query = "/corebuilding?$top=3";
var querySettings = new QuerySettings { ODataSettings = new ODataSettings { HandleNullPropagation = HandleNullPropagationOption.False, PageSize = 4 } };
Expand All @@ -429,7 +429,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingWithTopAndSmallerPageSizeNextLink()
public async Task BuildingWithTopAndSmallerPageSizeNextLink()
{
int pageSize = 2;
string query = "/corebuilding?$top=3";
Expand Down Expand Up @@ -470,7 +470,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingWithTopAndLargerPageSizeNextLink()
public async Task BuildingWithTopAndLargerPageSizeNextLink()
{
int pageSize = 4;
string query = "/corebuilding?$top=3";
Expand Down Expand Up @@ -506,7 +506,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void OpsTenantOrderByCountOfReference()
public async Task OpsTenantOrderByCountOfReference()
{
string query = "/opstenant?$expand=Buildings&$orderby=Buildings/$count desc";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -524,7 +524,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void OpsTenantOrderByFilteredCount()
public async Task OpsTenantOrderByFilteredCount()
{
string query = "/opstenant?$expand=Buildings&$orderby=Buildings/$count($filter=Name eq 'One L1') desc";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -544,7 +544,7 @@ void Test(ICollection<OpsTenant> collection)
//Exception: 'The Include path 'Mandator->Buildings' results in a cycle.
//Cycles are not allowed in no-tracking queries. Either use a tracking query or remove the cycle.'
[Fact]
public async void CoreBuildingOrderByCountOfChildReferenceOfReference()
public async Task CoreBuildingOrderByCountOfChildReferenceOfReference()
{
string query = "/corebuilding?$expand=Tenant($expand=Buildings)&$orderby=Tenant/Buildings/$count desc";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -561,7 +561,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void CoreBuildingOrderByPropertyOfChildReferenceOfReference()
public async Task CoreBuildingOrderByPropertyOfChildReferenceOfReference()
{
string query = "/corebuilding?$expand=Builder($expand=City)&$orderby=Builder/City/Name desc";
Test(Get<CoreBuilding, TBuilding>(query));
Expand Down
10 changes: 5 additions & 5 deletions AutoMapper.OData.EFCore.Tests/GetQuerySelectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public GetQuerySelectTests(GetQuerySelectTestsFixture fixture)
#endregion Fields

[Fact]
public async void OpsTenantSelectNameExpandBuildings()
public async Task OpsTenantSelectNameExpandBuildings()
{
string query = "/opstenant?$select=Name&$expand=Buildings&$orderby=Name";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -47,7 +47,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void OpsTenantExpandBuildingsFilterEqAndOrderBy_FirstBuildingHasValues()
public async Task OpsTenantExpandBuildingsFilterEqAndOrderBy_FirstBuildingHasValues()
{
string query = "/opstenant?$top=5&$select=Buildings&$expand=Buildings&$filter=Name eq 'One'&$orderby=Name desc";
Test(Get<OpsTenant, TMandator>(query));
Expand All @@ -66,7 +66,7 @@ void Test(ICollection<OpsTenant> collection)
}

[Fact]
public async void BuildingSelectNameExpandBuilder_BuilderNameShouldBeSam()
public async Task BuildingSelectNameExpandBuilder_BuilderNameShouldBeSam()
{
string query = "/corebuilding?$top=5&$select=Name&$expand=Builder($select=Name)&$filter=Name eq 'One L1'";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -85,7 +85,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderSelectNamefilterEqAndOrderBy()
public async Task BuildingExpandBuilderSelectNamefilterEqAndOrderBy()
{
string query = "/corebuilding?$top=5&$expand=Builder($select=Name)&$filter=Name eq 'One L1'";
Test(Get<CoreBuilding, TBuilding>(query));
Expand All @@ -104,7 +104,7 @@ void Test(ICollection<CoreBuilding> collection)
}

[Fact]
public async void BuildingExpandBuilderSelectNameExpandCityFilterEqAndOrderBy_CityShouldBeExpanded_BuilderNameShouldBeSam_BuilderIdShouldBeZero()
public async Task BuildingExpandBuilderSelectNameExpandCityFilterEqAndOrderBy_CityShouldBeExpanded_BuilderNameShouldBeSam_BuilderIdShouldBeZero()
{
string query = "/corebuilding?$top=5&$expand=Builder($select=Name;$expand=City)&$filter=Name eq 'One L1'";
Test(Get<CoreBuilding, TBuilding>(query));
Expand Down
Loading
Loading