08-27-2019 02:37 AM
We've posted this before, but it still doesn't seem to work.
Why can't we do this:
/api/contacts?$filter=customFields/fact_betaald eq 'NEE'&$top=100&$select=id,fullName&$expand=customFields($select=fact_betaald)
Like we do this:
api/contacts?$filter=customFields/fact_betaald eq 'NEE'&$top=100&$select=id,fullName&$expand=businessAddress($select=city)
If we do the expand on customFields we get:
"Could not find a property named 'customFields' on type 'act.web.api.models.Contacts.Contact'."
09-06-2019 10:22 AM
The reason why $select or $expand doesn't work with custom fields is because customfields is just a collection of name value pairs (.NET dictionary<string, object>) and OData doesn't handle it the same as a complex type or related entity like businessAddress. Microsoft OData $select|$expand doesn't seem to natively support this type. Another issue that is causing this is that custom fields are not included on the OData IEDM models (design time model) because custom fields are dynamicly loaded (run time - no model). To fix this issue the IEdm models would need to be built dyanmicly (like the API handles custom tables) with the metadata and not rely on hard-coded models.