I have a simple NHiberntate linq query:
var queryable = session.Linq<Product>().Where(p => p.Active);
Product[] products = queryable.ToArray();
The moment the ToArray()
is executed the session becomes dirty (session.IsDirty()
returns true
).开发者_Go百科 If the transaction is commited there is an UPDATE SQL query generated for each product.
Why are the products marked as dirty after a simple SQL SELECT?
In this project we are using the folowing framework/tools:
- .Net 3.5 + WPF
- NHibernate 2.1.2 + FluentNHibernate
- SQlite
- PostSharp 1.5
this problem is called "Ghost"
this test will detect this kind of problems: http://fabiomaulo.blogspot.com/2008/10/how-test-your-mappings-ghostbuster.html
this is my improvement, is a little bit more verbose, and thus it will give you more information: http://jfromaniello.blogspot.com/2010/02/nhibernate-ghostbuster-version-11.html
精彩评论