Bonjour,

commencons par la description de ma solution :
un projet web : couche présentation
un projet business : couche service
un projet DTOFactory : couche d'accès aux données
un projet DTO : couche de données

Base de données Oracle 11g.

Je suis donc en train de tester NHibernate.
Ci-joint la config nhibernate

Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <configSections>
      <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
   </configSections>
 
   <!-- HIBERNATE ZONE -->
   <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.MySqlDataDriver</property>
			-->
         <property name="dialect">NHibernate.Dialect.MySQLDialect</property>
         <property name="connection.connection_string">
            Data Source=OUTILS11;User Id=SPC_MNGR;Password=SPC_MNGR;Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;Incr Pool Size=5;Decr Pool Size=2;
         </property>
         <property name="show_sql">false</property>
         <mapping assembly="webGRAM.DTO"/>
      </session-factory>
   </hibernate-configuration>
</configuration>

Ensuite j'ai une classe qui s'appelle monServiceDTO qui représente ma table MON_SERVICE
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
namespace webGRAM.DTO
{
   public class monServiceDTO : objectDTO
   {
      public virtual int svcId { get; set; }
      public virtual string svcLabel { get; set; }
      public virtual string svcDatacenter { get; set; }
      public virtual string svcTeam { get; set; }
      public virtual string svcFncpic { get; set; }
      public virtual string svcRef { get; set; }
 
      public monServiceDTO()
      {
      }
 
      public monServiceDTO(int pId, string pLabel, string pDatacenter, string pTeam, string pFncpic, string pRef)
      {
         svcId = pId;
         svcLabel = pLabel;
         svcDatacenter = pDatacenter;
         svcTeam = pTeam;
         svcFncpic = pFncpic;
         svcRef = pRef;
      }
   }
}

avec le mapping associé monServiceDTO.hbm.xml
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="webGRAM.DTO" assembly="webGRAM.DTO">
   <class name="monServiceDTO" table="MON_SERVICE">
      <id name="svcId" column="SVC_ID" unsaved-value="0">
         <generator class="native" />
      </id>
      <version name="svcLabel" column="SVC_LABEL"/>
      <property name="svcDatacenter" column="SVC_DATACENTER" />
      <property name="svcTeam" column="SVC_TEAM" />
      <property name="svcFncpic" column="SVC_FNCPIC" />
      <property name="svcRef" column="SVC_REF" />
   </class>
</hibernate-mapping>

et enfin mon appel à la base de données :
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
        sessionFactory = new Configuration().Configure().BuildSessionFactory();
 
         // ouverture session 
         using (ISession session = sessionFactory.OpenSession())
         {
            ISQLQuery query = session.CreateQuery("SELECT svc_id, svc_lbl, svc_datacenter, svc_team, svc_fncpic, svc_ref FROM mon_service");
            IList<monServiceDTO> mesapplis = query.List<monServiceDTO>();
         }

Lors de l'exécution j'obtiens l'erreur suivante :
in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query) [SELECT svc_id, svc_lbl, svc_datacenter, svc_team, svc_fncpic, svc_ref FROM mon_service]
J'ai lu qu'il fallait que mon fichier de description xml soit un Embedded File, ce que j'ai fait.

Avez-vous une idée ?