Mercurial > altnet-hispano
comparison 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 |
comparison
equal
deleted
inserted
replaced
139:18e5a78186e4 | 140:3639803112c6 |
---|---|
1 using AltNetHispano.Agendas.Domain; | 1 using System; |
2 using System.Collections.Generic; | |
3 using System.Data; | |
4 using AltNetHispano.Agendas.Domain; | |
2 using ConfOrm; | 5 using ConfOrm; |
3 using ConfOrm.NH; | 6 using ConfOrm.NH; |
4 using NHibernate; | 7 using NHibernate; |
5 using NHibernate.Cfg; | 8 using NHibernate.Cfg; |
6 using NHibernate.Tool.hbm2ddl; | 9 using NHibernate.Tool.hbm2ddl; |
10 using NHibernate.Type; | |
11 using NHibernate.UserTypes; | |
7 | 12 |
8 namespace Agendas.NHibernate | 13 namespace Agendas.NHibernate |
9 { | 14 { |
10 public static class NhHelper | 15 public static class NhHelper |
11 { | 16 { |
17 if (_cfg == null) | 22 if (_cfg == null) |
18 { | 23 { |
19 var orm = new ObjectRelationalMapper(); | 24 var orm = new ObjectRelationalMapper(); |
20 orm.TablePerClass<Persona>(); | 25 orm.TablePerClass<Persona>(); |
21 orm.TablePerClass<Evento>(); | 26 orm.TablePerClass<Evento>(); |
27 | |
28 orm.Complex<Evento>(e => e.Estado); | |
29 | |
22 orm.TablePerClass<Track>(); | 30 orm.TablePerClass<Track>(); |
23 orm.TablePerClass<TrackLog>(); | 31 orm.TablePerClass<TrackLog>(); |
24 orm.TablePerClass<Cuenta>(); | 32 orm.TablePerClass<Cuenta>(); |
25 orm.TablePerClass<Patrocinador>(); | 33 orm.TablePerClass<Patrocinador>(); |
26 | 34 |
27 orm.Cascade<Evento, Persona>(Cascade.None); | 35 orm.Cascade<Evento, Persona>(Cascade.None); |
28 orm.Cascade<Persona, Evento>(Cascade.None); | 36 orm.Cascade<Persona, Evento>(Cascade.None); |
29 | 37 |
30 orm.Cascade<Persona, Cuenta>(Cascade.All | Cascade.DeleteOrphans); | 38 orm.Cascade<Persona, Cuenta>(Cascade.All | Cascade.DeleteOrphans); |
31 | 39 |
32 var mapper = new Mapper(orm); | 40 var mapper = new Mapper(orm); |
41 | |
42 mapper.AddPropertyPattern(p => p.DeclaringType == typeof(Evento) && p.Name == "Estado", a => a.Type<EventoStateType>()); | |
33 | 43 |
34 var mapping = mapper.CompileMappingFor(typeof(Evento).Assembly.GetTypes()); | 44 var mapping = mapper.CompileMappingFor(typeof(Evento).Assembly.GetTypes()); |
35 | 45 |
36 _cfg = new Configuration(); | 46 _cfg = new Configuration(); |
37 _cfg.Configure(); | 47 _cfg.Configure(); |