Fluent NHIbernate 冻结很多
根据探查器,FluentConfiguration.BuildConfiguration
需要 24 秒才能完成。这是我用来获取配置的代码:
MsSqlConfiguration persistenceConfigurer = MsSqlConfiguration
.MsSql2005
.ConnectionString(connectionStringBuilder => connectionStringBuilder
.Server(server)
.Database(database)
.Username(userName)
.Password(password))
.ProxyFactoryFactory<ProxyFactoryFactory>()
.CurrentSessionContext<ThreadStaticSessionContext>()
.DoNot.ShowSql();
FluentConfiguration cfg = Fluently.Configure()
.Database(persistenceConfigurer)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ExecutorMap>());
return cfg.BuildConfiguration();
映射文件的数量是 19。Fluent NHibernate 工作这么长时间是常见的吗?可能是我的错吗?可能出了什么问题?
提前致谢。
According to profiler it takes 24 sec for FluentConfiguration.BuildConfiguration
to complete. Here's the code I use to get Configuration:
MsSqlConfiguration persistenceConfigurer = MsSqlConfiguration
.MsSql2005
.ConnectionString(connectionStringBuilder => connectionStringBuilder
.Server(server)
.Database(database)
.Username(userName)
.Password(password))
.ProxyFactoryFactory<ProxyFactoryFactory>()
.CurrentSessionContext<ThreadStaticSessionContext>()
.DoNot.ShowSql();
FluentConfiguration cfg = Fluently.Configure()
.Database(persistenceConfigurer)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ExecutorMap>());
return cfg.BuildConfiguration();
The number of map-files is 19. Is it common for Fluent NHibernate to work so long? Might it be my fault? What could be wrong?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用分析器,您应该能够看到
BuildConfiguration
内部的调用占用了该时间。这些是什么?我的猜测是装配扫描。包含映射的程序集是否特别大?您已经告诉 Fluent NHibernate 扫描程序集以查找映射,因此无论映射有多少,它仍然必须扫描整个程序集以查找映射。
If you're using a profiler, you should be able to see what calls inside of
BuildConfiguration
are taking up that time. What are they?Assembly scanning would be my guess. Is the assembly that contains your mappings especially large? You've told Fluent NHibernate to scan your assembly for mappings, so regardless of how few mappings there are it still has to scan the entire assembly for them.