When updating a record from the Data Grid component, subsequent update attempts for the same record fail if the record has a null Navigation Property.
Data grid gets loaded with records using the getTable() method.
An update request is sent using ${Data} and ${Data.ID}
The successful update response includes expanded Navigation Properties. However if a navigation property is null the response includes a null value for that entity. This Null navigation property seems to create an issue for subsequent update requests.
The request Payload of subsequent update requests is different than that of the first successful update.
Attempting a second or subsequent update for this same record fails with
"The query specified in the URI is not valid. Could not find a property named 'Invoice' on type 'System.Collections.Generic.KeyValuePair_2OfString_Object'."
Where 'invoice' is the field for a null navigation property which was not there originally and only appeared after the initial update request.
Note:
I do not see this issue if I use the Form component. It appears that the FORM component handles the null navigation property and does not add any additional fields to subsequent update requests.
I am attaching an image from an excel workbook with captures of the request and response using both Form Component and Data Grid Component.
The problem is that the Invoice property is returned as null from the server after the first update. This could happen in one of two cases:
The corresponding related item doesn't exist. But then subsequent updates wouldn't have failed.
The Radzen datasource is out of sync with your database. This could happen if you change your database schema but do not infer the data source. I suspect this could be the case as I see InvoiceItem and Invoice properties that sound similar.
Please try inferring your data source again and see if this fixes the issue. If it doesn't you can send us your application and a copy of your DB (SQL script or backup) to info@radzen.com (as part of your Radzen Professional support plan).
@korchev
Thanks for the quick response.
Sending our entire database is a bit large. but I created a small subset that demonstrates the issue. I will sent this to info@radzen.com
the Datasource is in sync since I created the application this morning and no database changes were made. InvoiceItem and Invoice are two separate entities. Invoice is a navigation property and is in fact null for this record. InvoiceIDFK is the related key which is null therefore the Navigation property should return a null Invoice entity.
Do you mean that you are using an external OData API which isn't created from Radzen? If yes then you would need to update your code a bit. The OData API doesn't allow navigation properties in PATCH requests. Radzen currently generates code that strips those for MS SQL data sources but doesn't do that for third party OData API's.
Can you send us an up to date version of your application to info@radzen.com? We need to inspect the generated code as we are not sure why it works for one data source and doesn't work for the other.