Need some design advice on my ORM for Immutable objects & ref passing

by Eric Schneider   Last Updated July 11, 2019 19:05 PM

I'm adding Immutable objects support to my Micro ORM called "Symbiotic"

In the case of a create, I need to pass back a newly created version of the value passed in because the object is immutable and I need to update the newly created identity. For non-immutable values I just set the identity property, but obviously I can't do that now. So I'm thinking of adding a new method called CreateImmutable() with a ref for the value and setting the value with the newly created immutable object with the new identity property value and possibly a changed RowVersion property also. The current method return value is the record changed count, so I want the leave that as is.

I know I could take the easy route and force private property setters, but I would rather support pure immutable types.

Does anyone have any thoughts or potential unforeseen issue on my approach?

current method:

public int Create(object value)

proposed new method:

public int CreateImmutable(ref object value)

Related Questions

At what point do immutable classes become a burden?

Updated December 14, 2017 02:05 AM

Favoring Immutability in Database Design

Updated December 07, 2018 08:05 AM