Mapping by code conventions

34 views
Skip to first unread message

Richard Wilde

unread,
Jul 13, 2011, 4:12:23 AM7/13/11
to nhu...@googlegroups.com

Hi,

 

I am playing with mapping by code and am wondering about conventions.

 

All of my mapping files share the same common functionality:-

 

1.       All table names are lowercase:-

Table("organisationincometype");

 

2.       All Bags have:-

bag.Cascade(Cascade.All | Cascade.DeleteOrphans)

and

bag.BatchSize(10)

and

                                action => action.OneToMany()

 

So my question is, is this possible to do via conventions? If so how as I have seen a couple of posts by Fabio but cannot fathom this out.

 

My code to configure and build session factory is:-

 

 

var mapper = new ModelMapper();

mapper.AddMappings(typeof(Organisation).Assembly.GetTypes());

 

var configure = new Configuration();

configure.DataBaseIntegration(x =>

                                  {

                                         x.Dialect<MySQL5Dialect>();

                                         x.ConnectionStringName = "db";

                                  }).CurrentSessionContext<WebSessionContext>();

 

var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();

configure.AddDeserializedMapping(mapping, "Domain");

 

SessionFactory = configure.BuildSessionFactory();

 

 

Thanks

Rippo

 

 

 

Richard Wilde

unread,
Jul 15, 2011, 6:21:22 AM7/15/11
to nhu...@googlegroups.com

I am not sure whether I have asked a stupid question, an unanswerable question or nobody has picked up on this yet...

Can anyone offer any guidance?

Many thanks

 

------------------------------------------------

Maximilian Raditya

unread,
Jul 15, 2011, 6:46:01 AM7/15/11
to nhu...@googlegroups.com
So what have you tried along with the result? I think it can be done, though I haven't tried myself.
 
 
 
 
--
Regards,

Maximilian Haru Raditya
 
 


 

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.



José F. Romaniello

unread,
Jul 15, 2011, 6:57:06 AM7/15/11
to nhu...@googlegroups.com
Look at the BeforeMapClass event in this post;

http://fabiomaulo.blogspot.com/2011/04/nhibernate-32-mapping-by-code.html

You should do this with the mapper before building the mappings.

2011/7/13, Richard Wilde <ric...@wildesoft.net>:

> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to nhu...@googlegroups.com.
> To unsubscribe from this group, send email to
> nhusers+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

--
Enviado desde mi dispositivo móvil

Fabio Maulo

unread,
Jul 16, 2011, 1:13:40 PM7/16/11
to nhu...@googlegroups.com
Join to write a blog-post with this and others matters.

Richard Wilde

unread,
Jul 16, 2011, 1:25:06 PM7/16/11
to nhu...@googlegroups.com
Lol.  Ok you probably guessed I have started a blog and aim to keep it current with smallish tips.  However I am struggling with just the convention of making all my table names lowercase.  The cascade and batch size was very simple once I slapped my self for being stupid. 

I have a couple of blog posts ready to push and will do the conventions one next week. 

Thanks fabio 

Sent from my iPhone

On 16 Jul 2011, at 18:13, Fabio Maulo <fabio...@gmail.com> wrote:

Join to write a blog-post with this and others matters.

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/rafuOwshwJYJ.

Fabio Maulo

unread,
Jul 16, 2011, 5:28:13 PM7/16/11
to nhu...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages