About how to configure nhib.pdf on ASP. net2.0 website and Visual Web Developer Express

Source: Internet
Author: User

In ASP. in the. NET project, the use of nhib.pdf always encounters the problem of being unable to load the configuration file. Just one hour ago, I found a solution from a foreign blog. address: http://derek-says.blogspot.com/2008/02/nhibernate-in-visual-web-developer.html.

 

Now I will explain how to configure it.

1. Create tables in the database, such as tb_department

2. Then write the corresponding class file. For example, the full name of the corresponding class is netfuture. nhibernateclass. nh_tb_department.

3. Add the configuration in webconfig. Here is my configuration file:

<Hibernate-configuration xmlns = "urn: nhibernate-configuration-2.2">
<Session-factory>
<Property name = "connection. provider">
Nhib.pdf. Connection. driverconnectionprovider
</Property>
<Property name = "dialect">
Nhib.pdf. dialect. mssql2000dialect
</Property>
<Property name = "connection. driver_class">
Nhib.pdf. Driver. sqlclientdriver
</Property>
<Property name = "connection. connection_string">
Data Source = (local); Integrated Security = true; initial catalog = db_personnelmanagesystem
</Property>
<Mapping Assembly = "app_code"/>
</Session-factory>
</Hibernate-configuration>

The red sentence seems to be the key.

4. Write the ing file corresponding to the class, such:

<? XML version = "1.0" encoding = "UTF-8"?>
<Hibernate-mapping xmlns = "urn: nhibernate-mapping-2.2" default-Lazy = "false">
<Class name = "netfuture. nhibernateclass. nh_tb_department, app_code" table = "tb_department">
<ID name = "inclumentid" column = "inclumentid" type = "int32" length = "4" unsaved-value = "0">
<Generator class = "native"/>
</ID>
<Property name = "departmentname" column = "departmentname" type = "string" length = "16"/>
<Property name = "Description" column = "Description" type = "string" length = "200"/>
<Property name = "managerid" column = "managerid" type = "string" length = "15"/>
</Class>
</Hibernate-mapping>
The red sentence is also the key.

5. Place the class and ing files in the app_code folder.

6. Write the Initialization Configuration code similar to the following Nhibernate:

Nhibernate. cfg. Configuration CFG = new Nhibernate. cfg. configuration ();
Cfg. adddirectory (new system. Io. directoryinfo (system. Web. httpcontext. Current. server. mappath (@"~ /App_code /")));

_ Factory = cfg. buildsessionfactory ();

In this way, the apping of the app_code folder is completed, and nhib.pdf will search for the configuration file.

 

I want to help you write your essay for the first time.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.