.net – Changing readonly properties on an object – Education Career Blog

I have the following scenario:
Modify function takes an input object, and calls the stored procedure to update the database. The stored procedure changes some columns, namely updated date, and updated by, among others and returns them back in a form of the dataset.
Now, I need to change these properties on the object. However, the updated by and updated date are read only and must remain that way.
I am wondering if anybody has suggestions about this conundrum? I want to avoid using reflection to set read only properties. Are there any other ways?
The objects are defined in assembly A and its constructors are internal.
We are in assembly B. Gotta love modularity…



You can always create a new object and set the properties on the new object. Pass the current object in as a ref to indicate (and allow) that the new object with the updated values will replace it.

Leave a Comment