Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
my configuration file is
XML
<?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">Data Source=SERVER\SQLSERVER2088R2;Initial Catalog=Northwind;Persist Security Info=True;User ID=sa;Password=mysystem;</property>
      <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
      <property name="show_sql">false</property>
      <property name='proxyfactory.factory_class'>NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
    </session-factory>
  </hibernate-configuration>
</configuration>


and my mappinfile is
XML
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="Sample.CustomerService.Domain" namespace="Sample.CustomerService.Domain" xmlns="urn:nhibernate-mapping-2.2">
  <class name="Customers" table="Customers"  >
    <id name="Customerid" column="CustomerID" />
    <property name="Companyname">
      <column name="CompanyName" sql-type="nvarchar" not-null="true" />
    </property>
    <property name="Contactname">
      <column name="ContactName" sql-type="nvarchar" not-null="false" />
    </property>
    <property name="Contacttitle">
      <column name="ContactTitle" sql-type="nvarchar" not-null="false" />
    </property>
    <property name="Address">
      <column name="Address" sql-type="nvarchar" not-null="false" />
    </property>
    <property name="City">
      <column name="City" sql-type="nvarchar" not-null="false" />
    </property>
    <property name="Region">
      <column name="Region" sql-type="nvarchar" not-null="false" />
    </property>
    <property name="Postalcode">
      <column name="PostalCode" sql-type="nvarchar" not-null="false" />
    </property>
    <property name="Country">
      <column name="Country" sql-type="nvarchar" not-null="false" />
    </property>
    <property name="Phone">
      <column name="Phone" sql-type="nvarchar" not-null="false" />
    </property>
    <property name="Fax">
      <column name="Fax" sql-type="nvarchar" not-null="false" />
    </property>
    <bag name="Customercustomerdemo">
      <key column="CustomerID" />
      <one-to-many class="Customercustomerdemo" />
    </bag>
    <bag name="Orders">
      <key column="CustomerID" />
      <one-to-many class="Orders" />
    </bag>
  </class>
</hibernate-mapping>

and class for this mapping is

C#
using System;
using System.Text;
using System.Collections.Generic;


namespace Sample.CustomerService.Domain {

    public class Customers
    {
        public Customers() { }
        public virtual string Customerid { get; set; }
        public virtual string Companyname { get; set; }
        public virtual string Contactname { get; set; }
        public virtual string Contacttitle { get; set; }
        public virtual string Address { get; set; }
        public virtual string City { get; set; }
        public virtual string Region { get; set; }
        public virtual string Postalcode { get; set; }
        public virtual string Country { get; set; }
        public virtual string Phone { get; set; }
        public virtual string Fax { get; set; }
    }
}

and session factory is
C#
public sealed class SessionFactory
   {
       private static volatile ISessionFactory iSessionFactory;
       private static object syncRoot = new Object();

       public static ISession OpenSession
       {
           get
           {
               if (iSessionFactory == null)
               {
                   lock (syncRoot)
                   {
                       if (iSessionFactory == null)
                       {
                           Configuration configuration = new Configuration();
                           configuration.AddAssembly(Assembly.GetCallingAssembly());
                           iSessionFactory = configuration.BuildSessionFactory();
                       }
                   }
               }
               return iSessionFactory.OpenSession();
           }
       }
   }


i am calling this by
C#
using (ISession session = SessionFactory.OpenSession)
            {
                IQuery query = session.CreateQuery("FROM Customers");
                IList<Customers> pInfos = query.List<Customers>();
                dgView.DataSource = pInfos;
            }


always giving errors mapping document cant compile ,help me please , i am new to nhibernate.
i downloaded nhibernate by visual studio option manage nuggets ,it added two dlls ,one is nhibernate other is Iesi.collections,
i dont think i need dlls like somewhat(bytecod.linfu ,or castle.dll) etc.
Posted
Updated 28-Apr-15 21:21pm
v3
Comments
Gorkhali 27-Aug-17 3:51am    
I am also getting the same error message.Was your problem fixed?If so,could you please help me ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900