将以下输出与我在Stack Overflow和互联网上看到的样本进行比较让我想知道我做错了什么,显然show_sql
和format_sql
属性都设置正确?
输出
NHibernate:
SELECT
book0_.Isbn as Isbn0_0_,
book0_.Title as Title0_0_,
book0_.Author as Author0_0_,
book0_.Publisher as Publisher0_0_,
book0_.Published as Published0_0_,
book0_.Pages as Pages0_0_,
book0_.InStock as InStock0_0_,
book0_.Description as Descript8_0_0_
FROM
Books book0_
WHERE
book0_.Isbn=@p0;
@p0 = '0596800959' [Type: String (0)]
Book.cs
public class Book
{
public string Isbn { get; set; }
public string Title { get; set; }
public string Author { get; set; }
public string Publisher { get; set; }
public DateTime Published { get; set; }
public int? Pages { get; set; }
public bool InStock { get; set; }
public string Description { get; set; }
}
Book.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Dotnet.Samples.NHibernate"
namespace="Dotnet.Samples.NHibernate">
<class name="Book" table="Books" lazy="false">
<id name="Isbn" />
<property name="Title" />
<property name="Author" />
<property name="Publisher" />
<property name="Published" />
<property name="Pages" />
<property name="InStock" />
<property name="Description" />
</class>
</hibernate-mapping>
hibernate.cfg.xml中
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSqlCeDialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</property>
<property name="connection.connection_string">Data Source=res/Catalog.sdf</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
</session-factory>
</hibernate-configuration>
任何建议都会非常感激。非常感谢。
更新
在回复评论时,我正在添加预期输出的样子(基本上是一个有效的SQL语句):
NHibernate:
SELECT
Isbn,
Title,
Author,
Publisher,
Published,
Pages,
InStock,
Description
FROM
Books
WHERE
Isbn = '0596800959'