JSON.NET and nHibernate Lazy Loading of Collections

I was facing the same problem so I tried to use @Liedman’s code but the GetSerializableMembers() was never get called for the proxied reference. I found another method to override: public class NHibernateContractResolver : DefaultContractResolver { protected override JsonContract CreateContract(Type objectType) { if (typeof(NHibernate.Proxy.INHibernateProxy).IsAssignableFrom(objectType)) return base.CreateContract(objectType.BaseType); else return base.CreateContract(objectType); } }

What’s the difference between session.Merge and session.SaveOrUpdate?

This is from section 10.7. Automatic state detection of the Hibernate Reference Documentation: saveOrUpdate() does the following: if the object is already persistent in this session, do nothing if another object associated with the session has the same identifier, throw an exception if the object has no identifier property, save() it if the object’s identifier … Read more

How to Eager Load Associations without duplication in NHibernate?

Fetching Collections is a difficult operation. It has many side effects (as you realized, when there are fetched more collections). But even with fetching one collection, we are loading many duplicated rows. In general, for collections loading, I would suggest to use the batch processing. This will execute more SQL queries… but not so much, … Read more