.net - Different access for a property from different layers -
say have status property in domain entity. property used know system status of object, , must used in read way in presentation layer. layer can't modify directly status property. instead, 1 application service have specific operations change status.
is there way make status property readonly presentation layer writeable application service? or i'm modeling in wrong way? i'm using .net.
a best practice decouple presentation model domain model. specifically, create view model , bind ui instead of domain object directly. view model can initialized passing domain object constructor. example:
class someentity { public string status { get; set; } } class someentityviewmodel { public someentityviewmodel(someentity e) { this.status = e.status; } public string status { get; private set; } }
in way, application service can change status view cannot directly.
Comments
Post a Comment