Software-develop-web

Source: Internet
Author: User

A wen scenario using the HTTP context, and a client that uses the Desktop. Use of the NHibernate framework

1 usingSystem;2 usingSystem.Collections.Generic;3 usingsystem.linq;4 usingsystem.text;5 6 usingNHibernate;7 usingnhibernate.cfg;8 usingsystem.web;9 Ten namespaceAgathas.Storefront.Repository.NHibernate.SessionStorage one { a     /// <summary> -     ///(after you have implemented the ability to save the session), you need some way to create the Session.  -     ///ability to use NHibernate to persist and retrieve business Entities.  the     /// </summary> -      public classsessionfactory -     { -         //Nhibernate.isessionfactory created by the session factory +         Private Staticisessionfactory _sessionfactory; -  +         //Initialize a          at          public Static voidInit () -         { -             //creating instances and configuring Assemblies -Configuration config =NewConfiguration (); -Config. Addassembly ("Agatha.Storefront.Repository.NHibernate"); -  in             //Log log4net - Log4net. Config.XmlConfigurator.Configure (); to  +             //Implementation Configuration - Config. Configure (); the  *             //Get Session Factory $_sessionfactory =Config. Buildsessionfactory ();Panax Notoginseng         } -  the         //Get Session Factory +         Private Staticisessionfactory getsessionfactory () a         { the             if(_sessionfactory = =NULL) + Init (); -  $             return_sessionfactory; $         } -  -         Private StaticISession getnewsession () the         { -             returngetsessionfactory (). Opensession ();Wuyi         } the  -          public StaticISession getcurrentsession () wu         { -Isessionstoragecontainer Sessionstoragecontainer = about Sessionstoragefactory.getsessionstoragecontainer (); $  -ISession currensession =sessionstoragecontainer.getcurrentsession (); -  -             if(currensession = =NULL) a             { +Currensession =getnewsession (); the Sessionstoragecontainer.store (currensession); -             } $  the             returncurrensession; the         } the  the     } -}
View Code

Software-develop-web

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.