NHibernate.cfg.xml文件配置

ExpandedBlockStart.gif 代码
                 NHibernate.cfg.xml文件配置

<? xml version = " 1.0 "  encoding = " utf-8 " ?>
< hibernate - configuration  xmlns = " urn:nhibernate-configuration-2.2 "   >
    
< session - factory name = " NHibernate.Test " >
        
< property name = " connection.driver_class " > NHibernate.Driver.SqlClientDriver </ property >
        
< property name = " connection.connection_string " >
      Data Source
= .;database = NHibernateSample; uid = sa;pwd = 123 ;
    
</ property >
        
< property name = " adonet.batch_size " > 10 </ property >
        
< property name = " show_sql " > true </ property >
        
< property name = " dialect " > NHibernate.Dialect.MsSql2000Dialect </ property >
        
< property name = " use_outer_join " > true </ property >
        
< property name = " command_timeout " > 10 </ property >
        
< property name = " query.substitutions " > true   1 false   0 , yes  ' Y ' , no  ' N ' </ property >
    
< mapping assembly = " DomainModel " />     
    
</ session - factory >
</ hibernate - configuration >
// 创建数据库
public   class  DataBase
    {
        
private   void  CreateDatabase()
        {
            Configuration cfg 
=   new  Configuration();
            cfg.Configure();
            SchemaExport schema 
=   new  SchemaExport(cfg);
            
// schema.Drop(true, false);
            schema.SetOutputFile( " log.txt " );
            schema.Create(
true false );
         }
     }

转载于:https://www.cnblogs.com/hubcarl/archive/2010/04/07/1706377.html

猜你喜欢

转载自blog.csdn.net/weixin_33720452/article/details/93817284