Guys is there a tutorial out there for NHibernate for 2005. App_Code is my assembly, however the below code bugs out with the following error
Unknown entity class: Authors
Code:
Dim cfg As Configuration = New Configuration
cfg.AddAssembly("App_Code")
Dim factory As ISessionFactory = cfg.BuildSessionFactory
Dim session As ISession
session = factory.OpenSession
Dim transaction As ITransaction
transaction = session.BeginTransaction
Dim objAuthor As New Authors
objAuthor.AuthorEmail = "paul@test.com"
objAuthor.AuthorName = "NHiver"
objAuthor.AuthorNotify = True
objAuthor.AuthorPassword = "Nhibernate"
objAuthor.IsAuthorAdmin = True
session.Save(objAuthor)
transaction.Commit()
session.Close()
'-----------------------------------------------------------------
Mapping file is stored in App_Globalresources is this correct? Or what directory should it be in? bin directory?
'------------------------------------------------------------------
Mapping directory - no idea how to set it as an embedded resource, cant find this option in VS 2005, perhaps this is a VS 2003 option only. Right clicking on the xML file in solution explorer just gives two properties in the property pane, filename and file location.
'----------------------------------------------------------------------
'------------------------------------------------------------------------------
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Authors" table="tbl_authors">
<id name="Id" column="fld_author_id" type="Int">
<generator class="identity" />
</id>
<property name="AuthorName" column="fld_author_name" type="String" length="40"/>
<property name="IsAuthorAdmin" column="fld_author_admin" type="Boolean" />
<property name="AuthorUserName" column="fld_author_user" type="String" length="40"/>
<property name="AuthorEmail" column="fld_author_email" type="String" length="40"/>
<property name="AuthorPassword" column="fld_author_pass" type="String" length="40"/>
<property name="AuthorNotify" column="fld_author_notify" type="Boolean"/>
</class>
</hibernate-mapping>
Many thanks in advance for any tips tricks for VS 2005.