Nobody's making you use ExposeConfiguration, and BuildConfiguration is there
so you can do things like you've shown.

On Thu, Jan 28, 2010 at 9:17 PM, Weston Binford <[email protected]> wrote:

> About a year ago, there was a discussion ( http://bit.ly/b8A4WN ) here
> about making the NHibernate Configuration available from the Fluent
> Configuration API using ExposeConfiguration().  However, I am curious
> why not just use FluentConfiguration.BuildConfiguration() instead of
> Fluent BuildSessionFactory() and then call BuildSessionFactory on the
> configuration directly.
>
> That would allow you to keep the configuration available for
> SchemaExport or other methods that take the configuration as a
> parameter.
>
> At a minimum, I would think that:
>
>    var cfg = Fluently.Configure()
>      .Database(/* database config */)
>      .Mappings(/* your mappings */)
>      .ExposeConfiguration(BuildSchema)
>      .BuildConfiguration();
>
>    var sessionFactory = cfg.BuildSessionFactory();
>
>    BuildSchema(cfg);
>
> is better than:
>
>    Fluently.Configure()
>      .Database(/* database config */)
>      .Mappings(/* your mappings */)
>      .ExposeConfiguration(BuildSchema)
>      .BuildSessionFactory();
>
> where BuildSchema looks like this:
>
>    private void BuildSchema(Configuration cfg)
>    {
>      new SchemaExport(cfg)
>        .Create(false, true);
>    }
>
> For example, early in development, I put a Rebuild Database button on
> my screen that lets me get to a clean database quickly.  Having the
> NHibernate configuration available makes that very easy.
>
> -Weston
>
> --
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<fluent-nhibernate%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en.

Reply via email to