发布:偶写的NHibernate代码生成器

1、结构


2、功能
    1) 可以生成CSharp 和 Xml 文件
    2) 支持SQL Server数据库
    3) 支持生成注释,根据数据库注释生成CSharp注释
    4) 支持生成主键,外键部分暂未实现,但是可以方便的加上
    5) 扩展比较方便,比如增加VB,J#的生成器,比较方便

3、源代码
    点此下载

4、生成实例
    CS文件
   
using System;

namespace Entity
{
    
public class UserInfo:BizObject
    
{
        
public UserInfo(){}

        
public UserInfo(int entID):base(entID){}

        
private int _UserID;
        
/// <summary>
        
/// 用户流水号
        
/// </summary>

        public int UserID
        
{
            
get{return _UserID;}
            
set{_UserID = value;}
        }


        
private string _UserUID;
        
/// <summary>
        
/// 用户唯一标识号
        
/// </summary>

        public string UserUID
        
{
            
get{return _UserUID;}
            
set{_UserUID = value;}
        }


        
private string _LoginName;
        
/// <summary>
        
/// 登录名
        
/// </summary>

        public string LoginName
        
{
            
get{return _LoginName;}
            
set{_LoginName = value;}
        }


        
private string _Password;
        
/// <summary>
        
/// 密码
        
/// </summary>

        public string Password
        
{
            
get{return _Password;}
            
set{_Password = value;}
        }


        
private string _Username;
        
/// <summary>
        
/// 用户名
        
/// </summary>

        public string Username
        
{
            
get{return _Username;}
            
set{_Username = value;}
        }


        
private int _DepartmentID;
        
/// <summary>
        
/// 部门ID
        
/// </summary>

        public int DepartmentID
        
{
            
get{return _DepartmentID;}
            
set{_DepartmentID = value;}
        }


        
private int _StationID;
        
/// <summary>
        
/// 岗位
        
/// </summary>

        public int StationID
        
{
            
get{return _StationID;}
            
set{_StationID = value;}
        }


        
private bool _IsValid;
        
/// <summary>
        
/// 是否有效
        
/// </summary>

        public bool IsValid
        
{
            
get{return _IsValid;}
            
set{_IsValid = value;}
        }


        
private DateTime _LastLoginTime;
        
/// <summary>
        
/// 上次登录时间
        
/// </summary>

        public DateTime LastLoginTime
        
{
            
get{return _LastLoginTime;}
            
set{_LastLoginTime = value;}
        }


        
private DateTime _LastLogoutTime;
        
/// <summary>
        
/// 上次注销时间
        
/// </summary>

        public DateTime LastLogoutTime
        
{
            
get{return _LastLogoutTime;}
            
set{_LastLogoutTime = value;}
        }


        
private string _Email;
        
/// <summary>
        
/// 电子邮件
        
/// </summary>

        public string Email
        
{
            
get{return _Email;}
            
set{_Email = value;}
        }


        
private string _Phone;
        
/// <summary>
        
/// 电话
        
/// </summary>

        public string Phone
        
{
            
get{return _Phone;}
            
set{_Phone = value;}
        }


        
private string _Mobile;
        
/// <summary>
        
/// 手机号码
        
/// </summary>

        public string Mobile
        
{
            
get{return _Mobile;}
            
set{_Mobile = value;}
        }


        
private int _OrderID;
        
/// <summary>
        
/// 显示顺序
        
/// </summary>

        public int OrderID
        
{
            
get{return _OrderID;}
            
set{_OrderID = value;}
        }


    }

}


    xml文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
    
<class name="Entity.UserInfo, Entity" table="UserInfo">
        
<id name="UserID" type="Int32" column="UserID">
            
<generator class="assigned" />
        
</id>
        
<property name="UserUID" type="String(50)" column="UserUID" />
        
<property name="LoginName" type="String(50)" column="LoginName" />
        
<property name="Password" type="String(50)" column="Password" />
        
<property name="Username" type="String(50)" column="Username" />
        
<property name="DepartmentID" type="Int32" column="DepartmentID" />
        
<property name="StationID" type="Int32" column="StationID" />
        
<property name="IsValid" type="Boolean" column="IsValid" />
        
<property name="LastLoginTime" type="DateTime" column="LastLoginTime" />
        
<property name="LastLogoutTime" type="DateTime" column="LastLogoutTime" />
        
<property name="Email" type="String(50)" column="Email" />
        
<property name="Phone" type="String(50)" column="Phone" />
        
<property name="Mobile" type="String(50)" column="Mobile" />
        
<property name="OrderID" type="Int32" column="OrderID" />
    
</class>
</hibernate-mapping>



呵呵 错误之处 在所难免 忘批评指正
posted @ 2005-05-24 19:11  quitgame  阅读(2783)  评论(9编辑  收藏  举报