基于NHibernate的留言本

留言本环境:access2003+  vs2005

 

整个留言本的类视图:

1.新建一个空的解决方案 NHibernateMessage

  依次建立项目Model,DAL,BLL,Command四个项目

2.Model项目处理

删除自动生成的class1.cs文件,新建message.cs文件其代码如下

 

ContractedBlock.gifExpandedBlockStart.gifCode
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace Model
ExpandedBlockStart.gifContractedBlock.gif
{
   
public class message
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{

ExpandedSubBlockStart.gifContractedSubBlock.gif        
public message() { }

ContractedSubBlock.gifExpandedSubBlockStart.gif        
字段#region 字段
        
private string _id= Guid.NewGuid().ToString();
        
private string _title;
        
private string _username;
        
private string _email;
        
private string _ip;
        
private string _content;
        
private DateTime _addtime;
        
private string _recontent;
        
private DateTime _retime;
        
private int _isshow;
        
#endregion


ContractedSubBlock.gifExpandedSubBlockStart.gif        
属性#region  属性
       [XmlElement(ElementName 
= "id")]
       
public virtual string id
ExpandedSubBlockStart.gifContractedSubBlock.gif       
{
ExpandedSubBlockStart.gifContractedSubBlock.gif           
get return this._id; }
ExpandedSubBlockStart.gifContractedSubBlock.gif           
set this._id=value;}
       }

       
        [XmlElement(ElementName 
= "title")]
        
public virtual string title
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get return this._title; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set this._title = value; }
        }

        [XmlElement(ElementName 
= "username")]
        
public virtual string username
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get return this._username; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set this._username = value; }
        }

        [XmlElement(ElementName 
= "email")]
        
public virtual string email
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get return this._email; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set this._email = value; }
        }

        [XmlElement(ElementName 
= "ip")]
        
public virtual string ip
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get return this._ip; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set this._ip = value; }
        }

        [XmlElement(ElementName 
= "content")]
        
public virtual string content
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get return this._content; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set this._content = value; }
        }

        [XmlElement(ElementName 
= "addtime")]
        
public virtual DateTime addtime
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get return this._addtime; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set this._addtime = value; }
        }

        [XmlElement(ElementName 
= "recontent")]
        
public virtual string recontent
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get return this._recontent; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set this._recontent = value; }
        }

        [XmlElement(ElementName 
= "retime")]
        
public virtual DateTime retime
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get return this._retime; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set this._retime = value; }
        }


        [XmlElement(ElementName 
= "isshow")]
        
public virtual int isshow
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get return this._isshow; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set this._isshow = value; }
        }

        
#endregion


    }

}

 

然后在与message.cs同目录下我们新建文件message.hbm.xml一便系统能够关联

message.hbm.xml代码如下【注意:关联xml文件的文件名应该为  关联类名.hbm.xml】

 

ContractedBlock.gifExpandedBlockStart.gifCode
<?xml version="1.0" encoding="utf-8" ?>

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">

  
<class name="Model.message, Model" table="tb_message">

    
<id name="id"  column="id"  type="System.String" >

      
<generator class="assigned" />

    
</id>

    
<property name="title"  type="System.String" />

    
<property name="username" type="System.String" />

    
<property name="email"  type="System.String" />
    
    
<property name="ip"  type="System.String" />
    
    
<property name="content"  type="System.String" />
    
    
<property name="addtime"  type="System.DateTime" />
    
    
<property name="recontent"  type="System.String" />
    
    
<property name="retime"  type="System.DateTime" />
    
    
<property name="isshow" type="System.Int32"/>

  
</class>

</hibernate-mapping>

在message.hbm.xml文件配置好后需要注意的是:

message.hbm.xml---右键属性--生成操作--设置为:嵌入的资源

3.web.config配置可以参教demo

demo下载地址:http://files.cnblogs.com/rhythmK/NHibernateMessage.rar

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/304716.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

腾讯招.NET要求以下几点,你准备好了吗?

今天是大年初七&#xff0c;上班第一天&#xff0c;你在关注什么&#xff1f;2021年跳槽季可能是近10年来最火爆的跳槽季&#xff0c;各HR都在摩拳擦掌&#xff0c;新的征程已开始&#xff0c;.NET开发者们&#xff0c;也该行动起来了&#xff01;上图是腾讯的.NET Core招聘标准…

python设置字符间距_python字符串处理以及字符串格式化

一、python字符串处理目录:1.算长度(len),某个元素出现的次数(count)2.切片 [ ],repr:把不可见字符显示出来3.查找 #find,rfind从右边查找4.字符串和列表之间的转换(split,join list)5.替换字符串replace #替换会生成新的字符串&#xff0c;原来的字符串不变6.类型转换7.编…

不得了,日本出版社竟是这样吸引死宅学编程的

此前日本出版社“翔泳社”推出 IT 专业用语拟人化的 IT 说明书&#xff0c;将书中相关名词用萌妹子来表现&#xff0c;并对其性格等方面进行了设定。 比如 HTTP 酱由于在互联网上应用最为广泛&#xff0c;经常与大家见面&#xff0c;因此被设计成了偶像。她与其它协议有着很好的…

mysql表空间权限_MySQL InnoDB表空间加密示例详解

前言从 MySQL5.7.11开始&#xff0c;MySQL对InnoDB支持存储在单独表空间中的表的数据加密 。此功能为物理表空间数据文件提供静态加密。该加密是在引擎内部数据页级别的加密手段&#xff0c;在数据页写入文件系统时加密&#xff0c;加密用的是AES算法&#xff0c;而其解密是在从…

Dapr 正式发布 1.0

年前我写了一篇博客《Dapr 已在塔架就位 将发射新一代微服务》&#xff0c; 今天Dapr 正式发布了1.0 &#xff1a;Dapr Runtime v1.0.0Dapr dotnet SDK v1.0.0随着Dapr 发布1.0 版本&#xff0c; .NET团队编写的《Dapr for .NET Developers》&#xff1a;https://github.com/do…

帮助别人是一种快乐!

帮助人是一种快乐&#xff01;忽然之间想起的这种话题。其实&#xff0c;还是缘于最近看的一篇商界人物的文章《杨卓舒》其实&#xff0c;这些字眼一直都在我们的眼帘前晃荡&#xff0c;更多的人只是顿悟而已&#xff0c;也许还有人帮助过一次&#xff0c;获得了一次短暂的快乐…

python中x 1什么意思_Python:A [1:]中x的含义是什么?

这是array slice语法.看到这个问题&#xff1a;Explain Python’s slice notation对于列表my_list对象,例如[1,2,“foo”,“bar”],my_list [1&#xff1a;]相当于从0索引1开始的所有元素的浅复制列表&#xff1a;[2,“foo”,“bar”].所以你的for语句遍历这些对象&#xff1a;…

100 万在中国不同地方能活多久?

最近&#xff0c;一张名为 “100 万在中国各省能生活多久&#xff1f;” 的图片在网上流传 话不多说&#xff0c;往下看 没错&#xff0c;就是正如你们看到的 天朝大北京 以“100万能活19年9个月”的 成绩排名“倒数第一” 图片一出 数据君虎口一震 顿时一声惊叫 统计按“年人均…

JAVA跟MYSQL数据库交互_【编写Java程序实现与Mysql数据库的连接,并交互性的实现简单查询,删除,修改,排序,显示等操作】...

目前博主只实现了查询和插入&#xff0c;而且还不太会在面板对数据库语句进行更新&#xff0c;写完再看感觉语言有些冗杂&#xff0c;往后再更&#xff0c;大半夜写这个也是醉了呢。import javax.swing.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListe…

重磅:.NET 6 发布首个预览版

前言2021 年 2 月 17 日微软发布了 .NET 6 的 Preview 1 版本&#xff0c;那么来看看都有什么新特性和改进吧&#xff0c;由于内容太多了因此只介绍一些较为重点的项目。ASP.NET Core 6 Preview 1 和 EF Core 6 Preview 1 同样有很多的更新内容&#xff0c;但是限于篇幅就不在这…

热键与快捷键

热键及快捷键(GtkAccelGroup) 热键:一般是字母带下划线.在当前控件内(如打开的菜单)可以用alt字母来代替点击的功能快捷键:一般指,在本窗口任何位置内,按某组合键,都可以代替点击的功能.:) 如果你的理解与我的有冲突,请以我的理解为准!试举例证:#include #include const char *…

python服务器qt客户端_python3+PyQt5 创建多线程网络应用-TCP客户端和TCP服务器实例...

本文在上文的基础上重新实现支持多线程的服务器。以下为TCP客户端的程序代码&#xff1a;#!/usr/bin/env python3import sysfrom PyQt5.QtCore import (QByteArray, QDataStream, QDate, QIODevice,QRegExp, Qt)from PyQt5.QtWidgets import (QApplication, QDateEdit, QFrame,…

巧合?模仿还是抄袭?水木年华的《秋日恋歌》和Lube 乐队的《Pozovi Menya Tiho Po Imeni》...

今天听到了俄罗斯的Lube 乐队的《Pozovi Menya Tiho Po Imeni》&#xff0c;前奏感觉很好熟悉&#xff0c;继续听&#xff0c;有种似曾相识的感觉&#xff0c;曲风和演唱风格都很熟悉&#xff0c;我极力的回忆&#xff0c;依稀想起水木年华有一首《莫斯科的黄昏》的演唱风格是在…

UOS简单评测

一位网友安装了UOS系统&#xff0c;并录制了视频&#xff0c;这位网友告知&#xff0c;UOS使用中无卡顿&#xff0c;比较流畅。以下为机器的硬件配置。就操作系统最关键的软件生态而言&#xff0c;UOS自带40多款原创应用和一个有2000多款优质应用的商店&#xff0c;包括微信、Q…

python使用opencv查找轮廓_Python+opencv学习记录20:轮廓发现,Pythonopencv

1.轮廓发现轮廓发现是基于图像边缘提取的基础寻找对象轮廓的方法&#xff0c;所以边缘提取的阈值选定会影响最终轮廓发现结果。1.1发现轮廓在此步骤中我们会使用到findContours这个API&#xff0c;其原型为&#xff1a;cv2.findContours(image, mode, method[, contours[, hier…

今天,送你一份交通行业最全数据集(共享单车、自动驾驶、网约出租车、交通信号识别)

近几年来共享单车、自动驾驶等交通行业发展得如荼如火&#xff0c;小编也一直有意识地收集相关数据集&#xff0c;经过长时间的积累和沉淀&#xff0c;已经拥有将近300G的交通数据&#xff0c;内容涵盖国内外“自动驾驶”、“共享单车”、“网约出租车”、“交通信号识别”等方…

空谈Saas都扯淡,让你看看真正的云计算

最近“虚拟化”的话题似乎热度有所降低&#xff0c;而“云计算”的概念却不断升温&#xff0c;就连Vmware的新的服务器虚拟化产品&#xff0c;都要加上一个第一款“云计算”操作系统&#xff0c;而正如hubisheng兄弟在《名头不小&#xff01;&#xff01;VMware vSphere实为VI升…

重要的是改变命运,而非升职加薪

阅读本文大概需要4分钟。写公众号以来&#xff0c;被问的最多的问题就是工作选择。在这件事上&#xff0c;很多读者明显会更重视薪资、福利、Title&#xff0c;而不是&#xff1a;未来会怎么样。就在昨天&#xff0c;又有一个读者问我Offer选择的问题&#xff0c;给出建议后&am…

python中的成员运算符是干嘛的_在Python中使用成员运算符的示例

下表列出了所有Python语言支持的成员运算符。例如&#xff1a;试试下面的例子就明白了所有的Python编程语言提供会员运算符&#xff1a;#!/usr/bin/pythona 10b 20list [1, 2, 3, 4, 5 ];if ( a in list ):print "Line 1 - a is available in the given list"else…

前方高能 | 你写过什么有趣的程序?最后一个笑出猪叫

苍冥 说&#xff1a;我们从高一到高三都强制采用图形计算器&#xff0c;可以画函数图像的那种。我们用的是德州仪器系列&#xff0c;Ti-Nspire&#xff0c;贵的要死要死的。然而我却买错了计算器的制式&#xff0c;便宜货&#xff0c;相比其他同学的系统少了很多重要的功能。作…