This is a pretty simple question but I'm baffled by it. In the immediate window of Visual Studio, I see this:
session.CacheMode
Ignore
session.CreateQuery("SELECT COUNT(*) FROM Protein").List()
Count = 1
[0]: 0
session.CreateSQLQuery("SELECT COUNT(*) FROM Protein").List()
Count = 1
[0]: 6
There could be several causes for something like this, check your mappings for the following:
<class>
mapping with a where
filter. <discriminator>
with force="true"
attribute. <join>
mapping that doesn't match on one side and isn't specified as optional="true"
. <loader query-ref="...">
for the entity. <filter>
on the entity that has been enabled through session.EnableFilter
. Protein
isn't mapped to the Protein
table. Protein
in different schemas, so NHibernate is querying foo.Protein
but your sql is querying dbo.Protein
. After that it starts to get more esoteric such as using custom dialects, entity tuplizers, etc.
One simple way to see what is going on is to look at the SQL being issued, you can do this by:
<property name="show_sql" value="true"/>
and watching the console/logger.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.