Well i figured out the code after i posted but it still doesnt work
and I cant figure out why. My code follows. Although i generate an
nhibernate configuration in a different class i am still trying to set
the dialect explicitly (as shown below) but it still doesnt work.

            NHibernateFacility nhibernateFacility = new
NHibernateFacility(new NHibernateConfigurationBuilder());

            MutableConfiguration confignode = new MutableConfiguration
("nhibernate");
            MutableConfiguration factory = new MutableConfiguration
("factory");
            factory.Attributes.Add("id", "nhibernate.factory");
            confignode.Children.Add(factory);

            MutableConfiguration settings = new MutableConfiguration
("settings");
            MutableConfiguration item = new MutableConfiguration
("item");
            item.Attributes.Add("key", "dialect");
            item.Value = "NHibernate.Dialect.MsSql2005Dialect";
            settings.Children.Add(item);
            factory.Children.Add(settings);

            kernel.ConfigurationStore.AddFacilityConfiguration
("nhibernate", confignode);
            kernel.AddFacility("nhibernate", nhibernateFacility);

On Apr 30, 8:10 am, Tuna Toksoz <[email protected]> wrote:
> This feature is getting more and more demanded.
> I'll give it a go, making it work without configuration business, and if one
> wants to go further (such as configuring sessionfactory, I'll leave it to
> anther tool such as FNH.
>
> Victor's code will work for you, too.
>
> Tuna Toksöz
> Eternal sunshine of the open source mind.
>
> http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitter.com/tehlike
>
> On Thu, Apr 30, 2009 at 2:20 AM, Yannis <[email protected]> wrote:
>
> > Sorry I didnt write the way I meant to. I want to programmatically
> > create an nhibernate facility.
>
> > Currently I have a class that implements IConfigurationBuilder that as
> > follows:
>
> > public class NHibernateConfigurationBuilder : IConfigurationBuilder
> >    {
> >        #region IConfigurationBuilder Members
>
> >        public Configuration GetConfiguration(IConfiguration config)
> >        {
> >            NHibernateConnectionParameters connectionParameters = new
> > NHibernateConnectionParameters("test");
> >            return connectionParameters.CreateNHibernateConfiguration
> > ();
> >        }
>
> >        #endregion
> >    }
>
> > Then i am doing:
>
> > NHibernateFacility nhibernateFacility = new NHibernateFacility(new
> > NHibernateConfigurationBuilder());
> > kernel.AddFacility("nhibernate", nhibernateFacility);
>
> > but that results to an error: The NHibernateFacility requires an
> > external configuration
> > On Apr 29, 10:35 pm, Tuna Toksoz <[email protected]> wrote:
> > > Adding NHFacility for injecting to a service constructor? why?
>
> > > Tuna Toksöz
> > > Eternal sunshine of the open source mind.
>
> >http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitt...
>
> > > On Thu, Apr 30, 2009 at 12:32 AM, Yannis <[email protected]>
> > wrote:
>
> > > > is there any way to add an nhibernate facility programmatically and
> > > > associate it with a service constructor?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to