Fluent NHIbernate 冻结很多

发布于 2024-09-29 22:35:27 字数 1011 浏览 2 评论 0原文


根据探查器,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兮子 2024-10-06 22:35:27

如果您使用分析器,您应该能够看到 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文