diff Agendas/trunk/src/Agendas.NHibernate/NhHelper.cs @ 140:3639803112c6

Refactoring de la relación entre Evento y Estado
author nelopauselli
date Fri, 29 Jul 2011 16:30:53 -0300
parents 2d1adbaf0373
children 2dbb15f4510f
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.NHibernate/NhHelper.cs	Thu Jul 28 10:16:09 2011 -0300
+++ b/Agendas/trunk/src/Agendas.NHibernate/NhHelper.cs	Fri Jul 29 16:30:53 2011 -0300
@@ -1,9 +1,14 @@
-using AltNetHispano.Agendas.Domain;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using AltNetHispano.Agendas.Domain;
 using ConfOrm;
 using ConfOrm.NH;
 using NHibernate;
 using NHibernate.Cfg;
 using NHibernate.Tool.hbm2ddl;
+using NHibernate.Type;
+using NHibernate.UserTypes;
 
 namespace Agendas.NHibernate
 {
@@ -19,6 +24,9 @@
 				var orm = new ObjectRelationalMapper();
 				orm.TablePerClass<Persona>();
 				orm.TablePerClass<Evento>();
+
+				orm.Complex<Evento>(e => e.Estado);
+
 				orm.TablePerClass<Track>();
 				orm.TablePerClass<TrackLog>();
 				orm.TablePerClass<Cuenta>();
@@ -26,11 +34,13 @@
 
 				orm.Cascade<Evento, Persona>(Cascade.None);
 				orm.Cascade<Persona, Evento>(Cascade.None);
-				
+
 				orm.Cascade<Persona, Cuenta>(Cascade.All | Cascade.DeleteOrphans);
 
 				var mapper = new Mapper(orm);
 
+				mapper.AddPropertyPattern(p => p.DeclaringType == typeof(Evento) && p.Name == "Estado", a => a.Type<EventoStateType>());
+
 				var mapping = mapper.CompileMappingFor(typeof(Evento).Assembly.GetTypes());
 				
 				_cfg = new Configuration();