NHibernate auto-import

256 views
Skip to first unread message

Fernando Zago

unread,
Aug 15, 2008, 9:56:33 AM8/15/08
to nhu...@googlegroups.com
Hello guys....

I'm changing my framework to a newer version of NHibernate.
but, when a changed the version i have to change all xml mappings files
from xmlns="urn:nhibernate-mapping-2.0" to xmlns="urn:nhibernate-mapping-2.2".

and now, i have one other problem, NHibernate needs to add a attribute auto-import="false",
because auto-import defaults its "true", and its giving me an error >

The following types may not be used as proxies:
ContentManager.Noticias.Noticia: method get_Autor should be virtual


So, if i change "Noticia" mapping adding auto-import="false", it works,
but, i have on framework 350 mappings file.

So, in nhibernate configuration, have an option to change defaults from auto-import attributes ?
btw, i want to is there an default-lazy too ?

Thanks, cya

---
A vida me ensinou a nunca desistir,
nem ganhar, nem perder mas procurar evoluir.
Podem me tirar tudo que tenho!
Só não podem me tirar as coisas boas que eu já fiz pra quem eu amo!
E eu sou feliz e canto e o universo é uma canção eu vou que vou!

Randy Burden

unread,
May 15, 2012, 7:05:28 PM5/15/12
to nhu...@googlegroups.com
NHibernate now has the BeforeBindMapping event which gives you access to the object representation of the HBM XML files at runtime. You can use this event to set all mappings to auto-import="false" like so:

var configuration = new NHibernate.Cfg.Configuration();

configuration.BeforeBindMapping += (sender, args) => args.Mapping.autoimport = false;

Thanks,
--Randy Burden
Reply all
Reply to author
Forward
0 new messages