///
public System.String entity_prefix { }
private System.Int32 _entity_seq_length; ///
/// 自定义主键的自增长数字的长度 ///
public System.Int32 entity_seq_length { }
private System.String _entity_type; ///
/// 自定义主键的对象类别 ///
public System.String entity_type { }
get { return _entity_type; } set { _entity_type = value; } get { return _entity_seq_length; } set { _entity_seq_length = value; } get { return _entity_prefix; } set { _entity_prefix = value; }
[Column(IsIdentity=true)]
private System.String _entity_date; ///
/// 自定义主键的生成日期 ///
public System.String entity_date
private System.Int32 _entity_value; ///
/// 自定义主键的下一个值 ///
{ }
get { return _entity_date; } set { _entity_date = value; }
13
public System.Int32 entity_value { get { return _entity_value; } set { _entity_value = value; }
}
private System.Int32 _CorpID; ///
public System.Int32 CorpID {
get { return _CorpID; } set { _CorpID = value; } }
private String _date_format; ///
/// 自定义主键生成日期的格式 ///
public String date_format {
get { return _date_format; } set { _date_format = value; } }
private Int32 _add_value; ///
public Int32 add_value {
get { return _add_value; } set { _add_value = value; } }
private String _entity_suffix; ///
public String entity_suffix {
get { return _entity_suffix; } set { _entity_suffix = value; }
14
}
private Int32 _default_value; ///
public Int32 default_value {
get { return _default_value; } set { _default_value = value; } }
private Int32 _serial_no; ///
/// int类型自增主键值 ///
public Int32 serial_no {
get { return _serial_no; } set { _serial_no = value; } }
}
另外,如果用NHibernate做数据访问层,那所有的业务实体对象不仅要有结构定义,还要有与数据库中表的关系映射(即O/R Mapping)。 EntitySerialNO的O/R Mapping文件定义如下:
15
在
name定义的是实体对象类名,以“命名空间+类名,装配件名”表示,table属性定义的数据库中的表名。在 />中name属性定义的仍然是实体对象中的属性名,而column属性定义的是数据库表中的字段名。 由于FrameworkCore框架在数据持久层采用Nhibernate框架,所以上面的O/R Mapping内容 将被保存在名为EntitySerialNO.hbm.xml的文件中,且要在VS2003中被设为潜入的资源,以便被Nhibernate调用。 EntitySerialNO的数据库定义如下: create table dbo.EntitySerialNO ( entity_type nvarchar(50) not null, CorpID int not null, entity_prefix nvarchar(50) null, serial_no int not null, entity_value int null, entity_date datetime null, date_format nvarchar(50) null, entity_seq_length int null, add_value int null, default_value int null, entity_suffix nvarchar(50) null, memo nvarchar(50) null, constraint PK_ENTITYSERIALNO primary key (entity_type) ) go 2.1.3.4 数据访问 数据访问对象的目的是将业务逻辑与数据库进行隔离,以便使业务逻辑能支持更多的数据库而无需修改一行代码。FrameworkCore框架主要是使用Nhibernate和ADO.NET交互来支持这一块的功能。在FrameworkCore框架中共定义了四种Dao对象类型接口,具体如下: 1) IDao:定义所有对象访问数据库的操作接口。 /// /// Dao定义接口 /// public interface IDao { /// /// void Insert(IModel model); 16
相关推荐: