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); } }

How can C# nullable value typed values be set on NHibernate named IQuery parameters?

OK, it turns out there are some overrides on SetParameter that allow the type to be set explicitly. For example: query.SetParameter(position, null, NHibernateUtil.Int32); The full extension methods (for Int32 and DateTime only) are now: public static class QueryExtensions { public static void SetInt32(this IQuery query, int position, int? val) { if (val.HasValue) { query.SetInt32(position, val.Value); … Read more

ADO.NET Entity Framework vs NHibernate [closed]

NHibernate may be more mature. That does not necessarily mean it is a “better” solution. Having used it at my job for some time, I would personally prefer to use almost anything than NHibernate (even straight SQL, if migration were remotely feasible). The number of error messages thrown by NHibernate that don’t mean anything (or … Read more

NHibernate with TransactionScope

I have been using nHibernate 2.1 for awhile, and after a few production issues and trying quite a few variations, we have settled on the following method, as per Avoiding Leaking Connections With NHibernate And TransactionScope: using (var scope = new TransactionScope(TransactionScopeOption.Required)) { using (var session = sessionFactory.OpenSession()) using (var transaction = session.BeginTransaction()) { // … Read more

How to configure fluent nHibernate with MySQL

Change MsSqlConfiguration.MsSql2005, to MySqlConfiguration.Standard, it was the one thing I contributed to the project. Example: Fluently.Configure().Database( MySqlConfiguration.Standard.ConnectionString( c => c.FromConnectionStringWithKey(“ConnectionString”) ) ) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<MyAutofacModule>()) .BuildSessionFactory())

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)