vb.net - Is it possible to create an immutable property on a domain model? -


we have a number of logical domain objects reside in same physical database table workstep. simple sample of metadata in sql table id |name| type, such type fk table defines types possible. however, once selected database each row might represent different domain model, different business rules must applied. business rule working right once created, worksteptype property 1 of these objects can never change. so, call cause this change bad thing.

so, possible make object can constructed via add-ons automapper, , dapper, can have property set once. , never changed? also, types can not cast each other.

i haven't tried much, i'm not sure possible without hacky code

dapper maps private properties (or private setters/mutators).

public class workstep {     public worksteptype worksteptype { get; private set;} } 

if need resulting domain object specific type, make above class simple factory generates type looking for.

public class workstepfactory     {         public worksteptype worksteptype { get; private set;}  public t createworkstep<t>() t : workstepbase{...}      } 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -