I need to create DTOs from NHibernate POCO objects . The problem is that POCO objects contain dynamic proxies that should not be copied to the DTO. I look forward to downloading all collections and links that I need to transfer in advance, I do not want NHibernate to start downloading reference collections that I did not download in advance.
Several similar questions on SO got answers that:
- Suggest Session.GetSessionImplementation (). PersistenceContext.Unproxy ();
- Offer to disable Lazy Loading.
In my case, the first sentence does not matter, because, in my understanding, it causes download impatience to replace the proxy. In fact, it does not even work - it does not delete proxies in my objects. (Any explanation why?)
The second sentence, disabling lazy loading, seems to cause all links and collections to load, basically loading the entire database. My assumption was that if lazy loading is disabled and I did not request a collection, it will not be loaded. (Is it right that NHibernate does not offer such an option?)
I am using NHibernate 3.3.1 with a good configuration.
To repeat my main question, I need to create DTOs that clear proxies copied from POCOs that contain proxies, and I do not want to load data behind these proxies.
, ValueInjecter/AutoMapper, .
# 1:
, , , , - , ValueInjecter. . DTO , POCOs. , POCOs, .
, , , ( , , DTO ). , , .
ValueInjecter, DTO , . , ValueInjecter .
, - , , - ValueInjecter POCO / ?