質問

問題の説明:このモデルは、一度に1人のユーザーと正常に動作します。できるだけ早く私は、一度に複数のユーザーを取得するよう、私は私のSqlDataReaderのを閉じていないに関連するエラーの深刻なを取得します。私はこのような遅延ロードをオフにすると:

persistenceModel.Conventions.OneToManyConvention =(プロプ=> prop.SetAttribute)、( "怠惰" "偽");

それは素晴らしいです、まだパフォーマンスが遅いです。これは、MVCベータ1

を使用しています

任意の考え?

私の下には、私の世界ASAXのスニペットだけでなく、私のSessionFactory inializationコードを持っています。

これは私のGlobal.asaxにある********

***********
public class MvcApplication : NinjectHttpApplication
{
    public static IKernel Kernel { get; set; }

    protected override void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        //routes.IgnoreRoute("WebServices/*.asmx");

        routes.MapRoute("CreateCategoryJson", "Admin/CreateCategoryJson/{categoryName}");
        routes.MapRoute("User", "Admin/User/{username}", new { controller="Admin", action="user" });

        routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );

    }

    protected void Session_Start(object sender, EventArgs e)
    {
        if (Session["rSkillsContext"] == null)
        {
            string logonName = this.User.Identity.Name.Replace("NUSOFTCORP\\", string.Empty);
            rSkillsContext context = new rSkillsContext(logonName);
            Session.Add("rSkillsContext", context);
        }
    }

    protected override IKernel CreateKernel()
    {
        log4net.Config.XmlConfigurator.Configure();
        Kernel = new StandardKernel(new RepositoryModule(), new AutoControllerModule(Assembly.GetExecutingAssembly()), new Log4netModule());
        return Kernel;
    }
}

*****これは私のNHibernateHelper.csある******

    private ISessionFactory CreateSessionFactory()
    {
        var configuration = MsSqlConfiguration
                                .MsSql2005
                                .ConnectionString.FromConnectionStringWithKey("ConnectionString")
                                .ShowSql()
                                .Raw("current_session_context_class", "web")
                                .ConfigureProperties(new Configuration());

        var persistenceModel = new PersistenceModel();

        persistenceModel.Conventions.GetForeignKeyName = (prop => prop.Name + "ID");
        persistenceModel.Conventions.GetForeignKeyNameOfParent = (prop => prop.Name + "ID");
        // HACK: changed lazy loading
        persistenceModel.Conventions.OneToManyConvention = (prop => prop.SetAttribute("lazy", "false"));

        persistenceModel.addMappingsFromAssembly(Assembly.Load(Assembly.GetExecutingAssembly().FullName));
        persistenceModel.Configure(configuration);

        return configuration.BuildSessionFactory();
    }
役に立ちましたか?

解決

あなたが正しくあなたのセッションを配置しなかったこと(私はヶ月前NinjectとNHibernateのと同じエラーを持っていた)のように

に見えます。これは、リクエストの開始時に開始されなければならないとの端部に配置されるべきです。あなたがあなたのNHibernateのセッションを開始し、廃棄コードの断片を提供していただけますか?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top