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

1、结构
o_CodeGen.gif

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

3、源代码
    点此下载

4、生成实例
    CS文件
   
None.gif using  System;
None.gif
None.gif
namespace  Entity
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
public class UserInfo:BizObject
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
public UserInfo()dot.gif{}
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
public UserInfo(int entID):base(entID)dot.gif{}
InBlock.gif
InBlock.gif        
private int _UserID;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 用户流水号
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public int UserID
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _UserID;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_UserID = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string _UserUID;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 用户唯一标识号
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public string UserUID
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _UserUID;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_UserUID = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string _LoginName;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 登录名
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public string LoginName
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _LoginName;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_LoginName = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string _Password;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 密码
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public string Password
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _Password;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_Password = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string _Username;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 用户名
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public string Username
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _Username;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_Username = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private int _DepartmentID;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 部门ID
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public int DepartmentID
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _DepartmentID;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_DepartmentID = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private int _StationID;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 岗位
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public int StationID
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _StationID;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_StationID = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private bool _IsValid;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 是否有效
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public bool IsValid
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _IsValid;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_IsValid = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private DateTime _LastLoginTime;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 上次登录时间
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public DateTime LastLoginTime
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _LastLoginTime;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_LastLoginTime = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private DateTime _LastLogoutTime;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 上次注销时间
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public DateTime LastLogoutTime
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _LastLogoutTime;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_LastLogoutTime = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string _Email;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 电子邮件
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public string Email
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _Email;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_Email = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string _Phone;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 电话
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public string Phone
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _Phone;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_Phone = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string _Mobile;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 手机号码
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public string Mobile
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _Mobile;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_Mobile = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private int _OrderID;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 显示顺序
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public int OrderID
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return _OrderID;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{_OrderID = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

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



呵呵 错误之处 在所难免 忘批评指正

转载于:https://www.cnblogs.com/QuitGame/archive/2005/05/24/161671.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值