NHibernate1.2的配置和简单应用!!!!

it2022-05-05  117

1.web.config 配置

<!-- 必须有的配置节-->  <configSections>    <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />  </configSections>

  <nhibernate>    <add     key="hibernate.connection.provider"     value="NHibernate.Connection.DriverConnectionProvider" />    <add     key="hibernate.dialect"     value="NHibernate.Dialect.MsSql2000Dialect" />    <add     key="hibernate.connection.driver_class"     value="NHibernate.Driver.SqlClientDriver" />

   <!--数据库联接的配置节-->    <add     key="hibernate.connection.connection_string"     value="Server=192.168.1.67;initial catalog=NHibernate;User Id=sa;Password=sa;" />  </nhibernate>

2.映射文件

  注:映射文件必须存在<id> 标签要么会报错的!!<id> 标签映射的是数据表的 主键

<?xml version="1.0" encoding="utf-8" ?><hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"><class name="Entitys.login, Entitys" table="login" lazy="false">  <id  name="id" column="id" type="int" length="4">    <generator class="assigned" />  </id>   <property name="Uname" column="Uname" type="String" length="50" />   <property name="Upwd" column="Upwd" type="String" length="50" />   <property name="LastTime" column="LastTime" type="DateTime" /></class>

</hibernate-mapping>

3.实体类 

using System;

namespace Entitys{   /// <summary>   ///   ///功能描述:       ///开发者:       ///建立时间:       ///修订描述:       ///进度描述:       /// </summary>   public class login   {      private int m_id;      private string m_Uname;      private string m_Upwd;      private DateTime m_LastTime;

      public int id      {         get {  return m_id; }         set {  m_id = value; }      }

      public string Uname      {         get {  return m_Uname; }         set {  m_Uname = value; }      }

      public string Upwd      {         get {  return m_Upwd; }         set {  m_Upwd = value; }      }

      public DateTime LastTime      {         get {  return m_LastTime; }         set {  m_LastTime = value; }      }

   }}

转载于:https://www.cnblogs.com/xxj-jing/archive/2007/10/15/2890137.html

相关资源:各显卡算力对照表!

最新回复(0)