1.

Explain About Nhibernate Mapping Files?

Answer»

Mapping files form core of any database. These files contain field to field mapping, usually this mapping occurs between classes and ATTRIBUTES.

Sample mapping file:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
assembly="NhiberateSample" 
namespace="NhibernateSample.Sample">
<class name="FirstSample">
<id name="Id">
<generator class="native" />
</id>
<PROPERTY name="Name" />
<property name="Category" />
</class>
</hibernate-mapping>

No NEED to specify column name if database column name is same as property .

<property name="Name" column="database-column-name" />

Also, right-click on "FirstSample.hbm.xml", select "Properties" and change the "Build ACTION" to "Embedded Resource". 

The mapping file will now be a part of the Asssembly.

Mapping files form core of any database. These files contain field to field mapping, usually this mapping occurs between classes and attributes.

Sample mapping file:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
assembly="NhiberateSample" 
namespace="NhibernateSample.Sample">
<class name="FirstSample">
<id name="Id">
<generator class="native" />
</id>
<property name="Name" />
<property name="Category" />
</class>
</hibernate-mapping>

No need to specify column name if database column name is same as property .

<property name="Name" column="database-column-name" />

Also, right-click on "FirstSample.hbm.xml", select "Properties" and change the "Build Action" to "Embedded Resource". 

The mapping file will now be a part of the Asssembly.



Discussion

No Comment Found