-
Notifications
You must be signed in to change notification settings - Fork 153
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
Select query throw an error on a dynamic property dictionary #1224
Comments
Would you mind sharing a sample of what that model looks like as well? |
You can find the EDM model here : https://github.com/TARGAZ/ODataSelectDynamicPropertyBug/blob/main/Program.cs var modelBuilder = new ODataModelBuilder();
var customerType = modelBuilder.EntityType<Customer>();
customerType.HasKey(c => c.Id);
customerType.ComplexProperty(c => c.Name);
Type localizableStringType = typeof(LocalizableString);
ComplexTypeConfiguration localizableStringConfiguration = modelBuilder.AddComplexType(localizableStringType);
localizableStringConfiguration.AddDynamicPropertyDictionary(localizableStringType.GetProperty(nameof(LocalizableString.ExtendedProperties)));
modelBuilder.EntitySet<Customer>("Customers"); |
Oh I'm dumb, I didn't realize you provided a sample repo there, my bad @TARGAZ . |
Based on your code..... can you check whether replacing public Dictionary<string, object> ExtendedProperties IIRC, OData's EDM builder won't automatically match interfaces to implementations when they are found in the model. You either need to specify the type explicitly in that case, or just type it to the concrete type and it will be picked up automatically. Let us know if that changes the error in any way. |
Unfortunately, this doesn't work I have the same error. Note that the $filter works on this property. |
@TARGAZ OData needs the 'model type' as POCO class, so your 'LocalizableString' can't be treated correctly since it's derived from 'ReadOnlyDictionary< >'. If you replace your 'LocalizableString' definition using composition, not using inheritance, it should work: public sealed class LocalizableString/* : ReadOnlyDictionary<string, string>*/
{
private IDictionary<string, object> _values;
......
} |
Hello, |
Hello,
On a entity with a complex property that has dynamic property dictionary. I can't do a select clause on this complex property.
Assemblies affected
Microsoft.AspNetCore.OData 8.2.5
Reproduce steps
1.Clone the repository : https://github.com/TARGAZ/ODataSelectDynamicPropertyBug
2.Run
3.Try queries :
Expected result
First query : https://localhost:7092/odata/customers?$select=Name
Second Query : https://localhost:7092/odata/customers?$select=Name/en
Actual result
The error is the same for both queries :
Stack trace :
The text was updated successfully, but these errors were encountered: