开发者

Batch Size in web config for Nhibernate in ASP.NET MVC

How do I set the batch size for Nhibernate? I'd like to do this in the web.config. The examples I see, don't make a lot of sense to me.

In this example they are using code to set the batch size. I don't wnat to do that. I want it configurable in the web.config.

I understand how to add the config section, I just have read articles that differ on how to set this batch size. Most of them show batch size being set in code, and the ones that show it in the config use different names, or an appsettings key开发者_开发百科. Confusing.

When I add the config section into my web.config do I need to do anything special when creating the session or will nhibernate pick up the settings automatically?


in case anyone is wondering, I ended up just resorting to setting it up in my fluentnhibernate session factory.

Fluently.Configure().Database(
        FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2005
               .ConnectionString(c => c.FromConnectionStringWithKey("MyDatabase"))
               .AdoNetBatchSize(20)
)


I also had to resort to using code to configure, though I only override the batch size parameter and otherwise use the Web.config settings as-is:

Configuration configuration = new Configuration();
configuration.SetProperty(Environment.BatchSize, "0");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜