NHibernate.Linq:会话变为后选择脏NHibernate、Linq

2023-09-04 03:12:30 作者:醉在风里

我有一个简单NHiberntate LINQ查询:

I have a simple NHiberntate linq query:

var queryable = session.Linq<Product>().Where(p => p.Active);
Product[] products = queryable.ToArray();

当下的ToArray()执行会话变脏( session.IsDirty()返回)。如果该交易将提交有每个产品生成一个UPDATE SQL查询。

The moment the ToArray() is executed the session becomes dirty (session.IsDirty() returns true). If the transaction is commited there is an UPDATE SQL query generated for each product.

为什么产品标记为脏后,一个简单的SQL SELECT?

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

推荐答案

这个问题被称为鬼

此测试将检测到这样的问题: 的http://fabiomaulo.blogspot.com/2008/10/how-test-your-mappings-ghostbuster.html

this test will detect this kind of problems: http://fabiomaulo.blogspot.com/2008/10/how-test-your-mappings-ghostbuster.html

这是我的改善,更详细一点,因此它会给你更多的信息: 的http://jfromaniello.blogspot.com/2010/02/nhibernate-ghostbuster-version-11.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