WebApi
WebApi copied to clipboard
Incorrect OData query when collection is mapped as property using converter
issue found by @keatkeat87 and originally filed here: https://github.com/dotnet/efcore/issues/19628
Repro: 1.git clone https://github.com/keatkeat87/odata--select-HasConversion-issue.git 2.dotnet ef migrations add init 3.dotnet ef database update 4.F5 5.visit /odata/Products?$select=images
Problem here is that images is mapped as a property mapped using EFCore converters into json. However OData still recognizes it as a navigation collection, producing the following query:
DbSet<Product>()
.Select(namelessParameter{0} => new SelectSome<Product>{
ModelID = TypedLinqParameterContainer<string>.TypedProperty,
Container = new NamedPropertyWithNext0<IEnumerable<SelectAll<Image>>>{
Name = "images",
Value = namelessParameter{0}.images
.Select(namelessParameter{1} => new SelectAll<Image>{
ModelID = TypedLinqParameterContainer<string>.TypedProperty,
Instance = namelessParameter{1},
UseInstanceForProperties = True
}),
Next0 = new AutoSelectedNamedProperty<Nullable<int>>{
Name = "Id",
Value = (Nullable<int>)namelessParameter{0}.Id
}
}
} )
@xuzhg Are there any plans to fix this. My team is also running into this issue. Thanks for the help!
@maumar @Lusey77 From Microsoft.AspnetCore.OData v8.0.4, we can custom the SelectExpandBinder to generate a preferred LinQ expression