NHibernate slow mapping

Posted by Rob A on Stack Overflow See other posts from Stack Overflow or by Rob A
Published on 2009-12-31T16:39:18Z Indexed on 2010/05/17 1:50 UTC
Read the original article Hit count: 306

My question is what can I do to determine the cause of the slowness, or what can I do to speed it up without knowing the exact cause.

I am running a simple query and it appears that the mapping back to the entities is taking taking forever. The result set is 350, which is not much data in my opinion.

IRepository repo = ObjectFactory.GetInstance<IRepository>();
var q =  repo.Query<Order>(item => item.Ordereddate > DateTime.Now.AddDays(-40));

foreach (var order in q)
{
    Console.WriteLine(order.TransactionNumber);
}

The profiler is telling me it is executing the query 7ms / 35257ms, I am assuming that the former is the actual response from the db and the latter is the time it takes NH to do it's magic.

35 seconds is too long. This is a simple mapping, one table, nested components, using fluent interface to do mappings. I just start up a simple console app and run the one query, the slowness is measured after the SessionFactory is initialized, there should only be one session, and I am not using a transaction.

Thanks

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about fluent-nhibernate