Hi there, I am reading "NHibernate in action" ebook. And the first sample is to make simple console project using mssql 2000 dbase.
I already set up everything including the database, but there is an error :
"Could not instantiate dialect class NHibernate.Dialect.MsSql2000Dialect"
Anyone know the solution ?
thanks
open session method :
Code:
static ISession OpenSession()
{
if(factory == null)
{
Configuration c = new Configuration();
c.AddAssembly(Assembly.GetCallingAssembly());
factory = c.BuildSessionFactory();
}
return factory.OpenSession();
}
static ISessionFactory factory;
Employee class :
Code:
class Employee
{
public int id;
public string name;
public Employee manager;
public string SayHello()
{
return string.Format(
"'Hello World!', said {0}.", name);
}
}
app.config :
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="connection.connection_string">
Server=(local);database=HelloNHibernate;Integrated Security=SSPI;
</property>
<property name="dialect">
NHibernate.Dialect.MsSql2000Dialect
</property>
<property name="show_sql">
false
</property>
</session-factory>
</hibernate-configuration>
</configuration>
Employee.hbm.xml :
Code:
<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
auto-import="true">
<class name="HelloNHibernate.Employee, HelloNHibernate" lazy="false">
<id name="id" access="field">
<generator class="native" />
</id>
<property name="name" access="field" column="name"/>
<many-to-one access="field" name="manager" column="manager"
cascade="all"/>
</class>
</hibernate-mapping>