I think I'd do the same thing, except I'd wrap the whole bit of code
that needs the configuration object into the anonymous method part:
[SetUp]
public void SetUp()
{
var bootStrapper = new MediaManagerBootstrapper();
var sessionFactory = Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory)
.Mappings(m => m.AutoMappings.Add
(bootStrapper.AutoPersistenceModel))
.ExposeConfiguration(c =>
{
Session = sessionFactory.OpenSession();
var sessionSource = new SessionSource(
c.Properties,bootStrapper.AutoPersistenceModel);
sessionSource.BuildSchema(Session);
})
.BuildSessionFactory();
}
Which probably means the code that builds the schema should be
extracted to it's own method, right?
Regards,
Erik
On 6 feb, 01:33, Nic Strong <[email protected]> wrote:
> I have recently switched over to using the Fluent Configuration
> syntax. I have been using SessionSource from
> FluentNHibernate.Framework when doing my tests. The constructor
> requires the configuration properties from the nhibernate
> configuration. Is there a nice way to get at this from the
> FluentConfiguration?
>
> Currently I am using a workaround saving the Configuration from
> ExposeConfiguration():
>
> [SetUp]
> public void SetUp()
> {
> var bootStrapper = new MediaManagerBootstrapper();
> Configuration config = null;
> var sessionFactory = Fluently.Configure()
> .Database(SQLiteConfiguration.Standard.InMemory)
> .Mappings(m =>
> m.AutoMappings.Add(bootStrapper.AutoPersistenceModel))
> .ExposeConfiguration(c => { config = c; })
> .BuildSessionFactory();
>
> Session = sessionFactory.OpenSession();
> var sessionSource = new SessionSource(config.Properties,
> bootStrapper.AutoPersistenceModel);
> sessionSource.BuildSchema(Session);
> }
>
> Any suggestions?
>
> Nic
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---