Ciao ,
sto cercando di usare nhibernate per la prima volta.
Ho trovato un codice online (il classico helloworld). il problema è che non mi restituisce nulla dal DB.
Vi scrivo di seguito il codice e i file di configurazione:
CLASSE:
Namespace TheData
Public Class MessaggeProvider
Private _id As Integer
Private _msg As String
Public Sub New()
End Sub
Public Overridable Property Id() As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
_id = value
End Set
End Property
Public Overridable Property Message() As String
Get
Return _msg
End Get
Set(ByVal value As String)
_msg = value
End Set
End Property
End Class
End Namespace
FILE DI MAPPING (messageprovider.hbm.xml) Operazione di generazione impostato su "Risorsa incorporata"
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="property">
<class name="TheData.MessageProvider, WinHelloWorld" table="helloworld">
<id name="Id">
<generator class="identity"></generator>
</id>
<property name="Message"></property>
</class>
</hibernate-mapping>
FILE DI CONFIGURAZIONE (hibernate.cfg.xml)
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0" >
<session-factory>
<property name="dialect">
NHibernate.Dialect.MsSql2005Dialect
</property>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="connection.connection_string">
Server=LLORENZO; User Id=sa;Password=1a;Database=nhibernate
</property>
<mapping assembly="WinHelloWorld" />
</session-factory>
</hibernate-configuration>
CODICE:
Il database (MsSQL2005) ha la tabella helloworld con i campi Id e Message e sono state inserite tre righe.
Non ho errori in compilazione o a runtime, il problema è che non tira fuori nulla dal DB
Dov'è che sbaglio?