As far as we understand you would like to obtain access to a database calculated value for a field before the transaction has been committed. In your scenario the CategoryID
value is calculated by the database server. It is recommended to use the reference for the Category
to update it before it is committed as the backend calculated value cannot be retrieved without a call to the database. ORM tools do not afford to predict values generated by the database servers as the rules for the calculated values for the columns can vary greatly from one database application to another. We would therefore suggest you either commit the addition of the category so that you can later update the entity without guessing what the id might be or keep the reference to the added category in a local variable.
There is a scope operation which you can invoke to retrieve a not committed value but we would strongly advise you to use it sparingly as there are performance considerations you will need to take into account. You can flush the active transaction from the context by using our scope API. To expose the internal scope used by the OpenAccessContext
you can create a separate file in which you continue the definition of the OpenAccessContext
derived type in the following manner:
EntitiesModel : OpenAccessContext
IObjectScope scope =
We would like to point out again that this approach is not recommended and in your scenario we would try to keep the reference to the added category.
Should you have further questions, do not hesitate to contact us.
the Telerik team