Similar behavior could be achieved by our attach/detach api. After the persistent type is received as a parameter in your controller's action (or is reconstructed from a dto) it could be attached to a context. After doing so, Telerik Data Access
will identify the attached object by its primary key and will start tracking it. This means that any changes made to the attached object will be persistent in the database allowing you to just call .SaveChanges()
to update the entity. If a such record is not available in the database new record will be inserted.
To achieve that your controller's action could be modified in the following way:
id, Car carToUpdate )
carToUpdate.CarId = id;
Please note that the above approach will actually execute database query to retrieve the attached object as well. This is necessary because otherwise concurrency control issue could occur. Additionally, Telerik Data Access
would only update the required columns in the database. Please refer to this documentation article
for more detailed information on this feature.
Please let us know if you have any further questions.
OpenAccess ORM is now Telerik Data Access
. For more information on the new names, please, check out the Telerik Product Map