你的位置:首页 > 软件开发 > ASP.net > Fluent NHibernate and Mysql,SQLite

Fluent NHibernate and Mysql,SQLite

发布时间:2016-04-01 00:00:03
http://codeofrob.com/entries/sqlite-csharp-and-nhibernate.htmlhttps://code.google.com/archive/p/csharp-sqlite/downloadshttps://github.com/da ...

http://codeofrob.com/entries/sqlite-csharp-and-nhibernate.html

https://code.google.com/archive/p/csharp-sqlite/downloads

https://github.com/davybrion/NHibernateWorkshop

MySQL

 /// <summary>     ///MySQL 创建ISessionFactory     /// </summary>     /// <returns></returns>     public static ISessionFactory GetSessionFactory()     {       if (_sessionFactory == null)       {         lock (_objLock)         {           if (_sessionFactory == null)           {             //配置ISessionFactory             _sessionFactory = FluentNHibernate.Cfg.Fluently.Configure()               //数据库配置            .Database(FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard              .ConnectionString(c=>c.Server("")              .Database("geovindu")              .Password("520")              .Username("root"))              )                          .Mappings(m => m             //.FluentMappings.PersistenceModel             //.FluentMappings.AddFromAssembly();                        .FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly())) //用法注意                 .BuildSessionFactory();                      //  Fluently.Configure().Database(          //  MySqlConfiguration.Standard.ConnectionString(          //    c => c.FromConnectionStringWithKey("ConnectionString")          //  )          //)          //.Mappings(m => m.FluentMappings.AddFromAssemblyOf<MyAutofacModule>())          //.BuildSessionFactory())           }         }       }       return _sessionFactory;     }     /// <summary>     /// 重置Session     /// </summary>     /// <returns></returns>     public static ISession ResetSession()     {       if (_session.IsOpen)         _session.Close();       _session = _sessionFactory.OpenSession();       return _session;     }     /// <summary>     /// 打开ISession     /// </summary>     /// <returns></returns>     public static ISession GetSession()     {       GetSessionFactory();       if (_session == null)       {         lock (_objLock)         {           if (_session == null)           {             _session = _sessionFactory.OpenSession();           }         }       }       return _session;     }

原标题:Fluent NHibernate and Mysql,SQLite

关键词:MYSQL

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录