I would like to know if there is a way to make an instance of an object immutable at runtime. I know that I can only have readonly types, but I would like to see only type instances in runtime mode. The reason is because I want to use NH domain objects, such as a lightweight object, by changing properties, but I do not want these changes to be saved when Session.Flush () or similar is executed. There is always Session.Evict (), but this will not prevent the developer of unknown from Session.Save () for the readonly object.
At runtime, huh? I am still a little puzzled by what exactly you ask, but I did something similar in the past:
foreach (var order in orders) { _nhSession.SetReadOnly(order, true); //prevent database updates }
, , , , . , NHibernate , , , #, , NULL, 0 #,
, .
Source: https://habr.com/ru/post/1720836/More articles:Scrolling HTML page using javascript? - javascriptИспользование TCP для команд реального времени: алгоритм Nagle вызывает огромные задержки, что мне делать? - client-serverJQuery getJSON function - jsonPublisher Name Not Displayed in UAC - CertificateExclude exceptions from WS - c #Best way to manage connection strings in a project that contains both classic ASP and ASP.Net 1.1 code? - asp.netHow to use cp from stdin? - stdinDjango Testing Framework с дизайнерами для входа - они работают? Ошибка с обратным - djangophp - point for __get () and __set () magic - oopjquery to goto url on form submit with field values added to url string - jqueryAll Articles