views:

297

answers:

2

I'm using Ayende's NHibernate Linq version 2.1.2, available here, and when I use NHProf to inspect queries that use this method:

public IQueryable<T> GetAll()
{
    return Session.Linq<T>();
}

It gives me the warning that I'm using an implicit transaction. Problem is, I'm using this in a repository to abstract out the database session, but I still want the flexibility of returning an IQueryable so I can run any Linq query I want. Is there a way to explicitly wrap the Session.Linq<T>() in a transaction without exposing it, or should I just ignore the warning in this case?

A little more background. I'm using the method like so:

var repo = new Repository();
var animals = repo.GetAll<Animal>().Where(x => x.Size > 100);
NoahsArk.LargeAnimals.AddRange(animals);
A: 

I'm pretty sure you can ingnore this warning.

Can you see the transaction in NHProf?

http://groups.google.com/group/nhprof/browse%5Fthread/thread/fbc97d3286ad783b

Olivieri
+2  A: 

NHProf's message is actually not related to your repository implementation. It's just pointing out that you are running your query outside a transaction, which can be a source of problems.

Ayende explains this in a blog post: NH Prof Alerts: Use of implicit transactions is discouraged

You should manage your transactions from a higher level in your application. There are several ways to do this while using repositories, have a look at unhaddins

Diego Mijelshon