zoukankan      html  css  js  c++  java
  • Nhibernate和Sqlite数据库的使用

    hibernate.cfg.xml配置文件Sample:

    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
      <session-factory name="Rock">
        <!-- properties -->
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
        <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver, NHibernate</property>
        <property name="connection.connection_string">Data Source=D:\Data\SQLite_DB\rock.db;Version=3</property>
        <property name="dialect">NHibernate.Dialect.SQLiteDialect, NHibernate</property>
        <property name="query.substitutions">true=1;false=0</property>
        <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
        <property name="show_sql">false</property>
        <property name="use_outer_join">true</property>
        <!--
                these are different than the values in app.config so I can verify these
                are being picked up
            -->
        <property name="command_timeout">444</property>
        <!-- mapping files -->
        <!-- are now optional
                <mapping file="ABC.hbm.xml" />
                <mapping resource="NHibernate.DomainModel.Simple.hbm.xml" assembly="NHibernate.DomainModel" />
            -->
      </session-factory>

    </hibernate-configuration>

     

    自动增加主Key的Mapping的Sample:

    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false" namespace="Rock.Data.Model" assembly="Rock.Data.Model">
        <class name="PasswordMaster,Rock.Data.Model" table="PasswordMaster" lazy="false">

            <!-- Primary Key(s) -->
            <id name="Id" column="PwdKey" type="Int32" unsaved-value="0">
               <generator class="increment"/>
            </id>
            <!-- Properties -->
            <property column="PwdName" type="String" name="PwdName" not-null="true" length="50" />
            <property column="PwdID" type="String" name="Pwdid" not-null="true" length="50" />
            <property column="PwdValue" type="String" name="PwdValue" not-null="true" length="50" />
            <property column="WebSite" type="String" name="WebSite" length="50" />
            <property column="Q1" type="String" name="Q1" length="50" />
            <property column="A1" type="String" name="A1" length="50" />
            <property column="Q2" type="String" name="Q2" length="50" />
            <property column="A2" type="String" name="A2" length="50" />
            <property column="Q3" type="String" name="Q3" length="50" />
            <property column="A3" type="String" name="A3" length="50" />
            <property column="CreateDate" type="DateTime" name="CreateDate" not-null="true" />
            <property column="Remark" type="String" name="Remark" length="255" />
        </class>
    </hibernate-mapping>

     

    当然项目要引用System.Data.Sqlite.DLL这个文件。

  • 相关阅读:
    TTTTTTTTTTTTTTTTTTT UVA 2045 Richness of words
    hdu 5723 Abandoned country 最小生成树+子节点统计
    hdu 5792 World is Exploding 树状数组+离散化+容斥
    MySQL字符集详解
    MySQL的sql语言分类DML、DQL、DDL、DCL、
    MySQL5.6的4个自带库详解
    Win10下安装MySQL5.6
    {MySQL数据库初识}一 数据库概述 二 MySQL介绍 三 MySQL的下载安装、简单应用及目录介绍 四 root用户密码设置及忘记密码的解决方案 五 修改字符集编码 六 初识sql语句
    {python--GIL锁}一 介绍 二 GIL介绍 三 GIL与Lock 四 GIL与多线程 五 多线程性能测试
    Navicat安装及简单使用
  • 原文地址:https://www.cnblogs.com/rockniu/p/1592554.html
Copyright © 2011-2022 走看看