我的源代码是:
var cfg = new Configuration();
cfg.DataBaseIntegration(x =>
{
x.ConnectionString = "......";
x.Driver<SqlClientDriver>();
x.Dialect<MsSql2008Dialect>();
});
cfg.AddAssembly(Assembly.GetExecutingAssembly());
var sessionFactory = cfg.BuildSessionFactory(); //builds meta data and mapping
using (var session = sessionFactory.OpenSession())
using (var tx = session.BeginTransaction()) {
var customers = session.CreateCriteria<Customer>()
.List<Customer>();
foreach (var customer in customers) {
Console.WriteLine("{0} {1}", customer.FirstName, customer.LastName);
}
tx.Commit();
}
我的映射文件Customer.hbm.xml是:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:hibernate-mapping-2.2" assembly="ConsoleApplication1" namespace="ConsoleApplication1">
<class name="Customer">
<id name="Id">
<generator class="native"/>
</id>
<property name="FirstName"/>
<property name="LastName"/>
</class>
</hibernate-mapping>
我收到错误: nhibernate无法编译映射文件
有人知道为什么吗?