开发者

NHibernate.Linq : session becomes dirty after select

开发者 https://www.devze.com 2023-01-02 08:12 出处:网络
I have a simple NHiberntate linq query: var queryable = session.Linq<Product>().Where(p => p.Active);

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号