NHibernate in Action
Marco De Sanctis
http://blogs.ugidotnet.org/Crad
[email protected]
Domain Model Pattern
Perché usare un ORM?
Il progetto NHibernate
Perché NHibernate?
Per iniziare… Mapping delle Entity!
oppure
generato
automaticamente
Configurazione
<configSections>
<section name="nhibernate" type=“..." />
</configSections>
<nhibernate>
<add key="hibernate.connection.provider" value=“..." />
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
<add key="hibernate.connection.driver_class" value=“..." />
<add key="hibernate.connection.connection_string" value=“….connectionString..." />
</nhibernate>
...
Configuration cfg = new Configuration();
cfg.AddAssembly(“Sample");
factory = cfg.BuildSessionFactory();
...
La Session
Entity Lifecycle
Spazio della vostra applicazione
TRANSIENT
PERSISTENT
DETACHED
PERSISTENT
DETACHED
Scheduled actions
session
Transparent Write Behind
Dirty Checking
...
Anagrafica.DataNascita = ...
Anagrafica.Indirizzo.Cap = “...”
...
Gestione della concorrenza
Per aiutarvi con i file di mapping…
Codename
Supertanga
NHibernate Domain Mapper is a tool
that assists user creating NHibernate
Mapping Files. User may add his own
Domain Model assemblies and map
them to database table using a rich
UI, which will present him all the
suitable options regarding at the
element type he created. The
peculiarity of this tool is that it allows
doing the mapping task starting from
a domain model instead of a Database
schema.
Homepage su Codeplex:
http://www.codeplex.com/NHDomainMapper
Se avete un po’ di tempo da dedicarci…
entrate a far parte del team
di sviluppo, fama e gloria vi
attendono!!
Domande?
Scarica

NHibernate_In_Action_1