完成数据库的设计之后,进入实体类的创建。实体类的创建可以借助动软代码生成器
例如我们要创建一个会员实体类MemberInfo的创建
首先打开动软代码生成器->选择添加服务器->连接服务器->在数据库中找到相对应的表
选中时候,选择单表代码生成器:
进行相应的选择之后,选择生成代码:
using System;
namespace Maticsoft.Model
{
/// <summary>
/// MemberInfo:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class MemberInfo
{
public MemberInfo()
{}
#region Model
private int _id;
private int _cardid;
private string _cardnumber;
private string _name;
private string _ic;
private string _phone;
private string _address;
private DateTime _bdate;
/// <summary>
///
/// </summary>
public int ID
{
set{ _id=value;}
get{return _id;}
}
/// <summary>
///
/// </summary>
public int CardID
{
set{ _cardid=value;}
get{return _cardid;}
}
/// <summary>
///
/// </summary>
public string CardNumber
{
set{ _cardnumber=value;}
get{return _cardnumber;}
}
/// <summary>
///
/// </summary>
public string Name
{
set{ _name=value;}
get{return _name;}
}
/// <summary>
///
/// </summary>
public string IC
{
set{ _ic=value;}
get{return _ic;}
}
/// <summary>
///
/// </summary>
public string Phone
{
set{ _phone=value;}
get{return _phone;}
}
/// <summary>
///
/// </summary>
public string Address
{
set{ _address=value;}
get{return _address;}
}
/// <summary>
///
/// </summary>
public DateTime BDate
{
set{ _bdate=value;}
get{return _bdate;}
}
#endregion Model
}
}
项目中巧妙利用代码生成器可以极大减少工作量,提高工作效率。