在 NstarfaiNet 框架的使用示例(一)中已经对使用NStarfaiNet的应用框架的DAO和BLL做了简单的介绍。以下将继续对BLL进行补充说明,并示范生成的Model实体代码内容。
BLL: 自动生成的业务类代码不宜手动修改(如添加一些业务方法等),这样做是为了避免将来重新生成代码覆盖了自己添加的内容。开发者可以按照模块或者功能划分,手工添加一个新的BIZ业务类来处理其他业务逻辑。
/**//*
版权所有:版权所有(C) 2007 NStarfaiNet框架设计者
模块名称:NStarfaiNet.Test.BLL
完成日期:2006-08-20
设计作者:刘斌[liubin]
内容摘要:BaseBLL 的摘要说明。
*/
using System;
using System.Data;
using System.Runtime.Remoting.Messaging;
using NStarfaiNet.Test.Dao;
using NStarfaiNet.Access.Interface;
using NStarfaiNet.Test.Model.Interface;
namespace NStarfaiNet.Test.BLL
...{
/**//// <summary>
/// 业务基类
/// </summary>
public class BaseBLL
...{
自动生成代码#region 自动生成代码
protected IBaseDao m_Dao = null;
protected string m_AccessID = string.Empty;
/**//// <summary>
/// 无参构造函数
/// </summary>
protected BaseBLL()
...{
}
public const string NSTAR_DAO_SESSION = "_NSTAR_DAO_SESSION_";
/**//// <summary>
/// 获取当前线程的Dao会话信息
/// </summary>
public IBaseDao GetDAO()
...{
object o = CallContext.GetData(NSTAR_DAO_SESSION);
if (o == null)
...{
o = new BaseDao(m_AccessID);
CallContext.SetData(NSTAR_DAO_SESSION, o);
}
return (IBaseDao)o;
}
/**//// <summary>
/// <summary>
/// 方法名称: BeginTransaction
/// 内容摘要: 开启事务
/// </summary>
/// <returns>IDbTransaction</returns>
public IDbTransaction BeginTransaction()
...{
return this.GetDAO().DataAccess.BeginTransaction();
}
/**//// <summary>
/// 方法名称: CommitTransaction
/// 内容摘要: 提交事务
/// </summary>
public void CommitTransaction()
...{
this.GetDAO().DataAccess.CommitTransaction();
}
/**//// <summary>
/// 方法名称: RollBackTransaction
/// 内容摘要: 回滚事务
/// </summary>
public void RollBackTransaction()
...{
this.GetDAO().DataAccess.RollbackTransaction();
}
#endregion
}
}
Model:
此处以测试表bsi_test为例
1
/**//*
2
版权所有:版权所有(C) 2007 NStarfaiNet框架设计者
3
模块名称:NStarfaiNet.Test
4
完成日期:2006-08-20
5
设计作者:刘斌[liubin]
6
内容摘要:BsiTestEntity 的摘要说明。
7
*/
8
using System;
9
using NStarfaiNet.Access.Interface;
10
using NStarfaiNet.Test.Model.Interface;
11
12
namespace NStarfaiNet.Test.Model
13
{
14
/**//// <summary>
15
/// NStarfaiNet 测试实体类
16
/// </summary>
17
[TableAttribute(TableName="bsi_test")]
18
public class BsiTestEntity : BaseEntity,IBsiTestEntity
19
{
20
自动生成代码#region 自动生成代码
21
/**//// <summary>
22
/// 初始化。
23
/// </summary>
24
public BsiTestEntity()
25
{
26
}
27
28
public Key Key(decimal keyValue)
29
{
30
return new Key(this.GetType(), keyValue);
31
}
32
33
private decimal m_testId = 0;
34
35
/**//// <summary>
36
/// 测试ID(主键)。
37
/// </summary>
38
[FieldAttribute(FieldName="test_id",ParameterType=ParameterType.Int32,Length=50,DefaultValue="",IsPrimaryKey=true)]
39
public decimal TestId
40
{
41
set
{ m_testId = value; }
42
get
{ return m_testId; }
43
}
44
45
46
private string m_testName = System.String.Empty;
47
48
/**//// <summary>
49
/// 测试名称。
50
/// </summary>
51
[FieldAttribute(FieldName="test_name",ParameterType=ParameterType.Nvarchar,Length=100,DefaultValue="",IsPrimaryKey=false)]
52
public string TestName
53
{
54
set
{ m_testName = value;}
55
get
{ return m_testName; }
56
}
57
58
59
public override void CancelEdit()
60
{
61
62
}
63
#endregion
64
65
}
66
67
}
68
69
实体接口类:
1
/**//*
2
版权所有:版权所有(C) 2007 NStarfaiNet框架设计者
3
模块名称:NStarfaiNet.Test
4
完成日期:2006-08-20
5
设计作者:刘斌[liubin]
6
内容摘要:BsiTestEntity 的摘要说明。
7
*/
8
9
using NStarfaiNet.Access.Interface;
10
11
namespace NStarfaiNet.Test.Model.Interface
12
{
13
/**//// <summary>
14
/// NStarfaiNet 测试表实体接口。
15
/// </summary>
16
public interface IBsiTestEntity : IEntity
17
{
18
自动生成代码#region 自动生成代码
19
/**//// <summary>
20
/// 测试ID(主键)
21
/// </summary>
22
decimal TestId
{ get; set; }
23
24
/**//// <summary>
25
/// 测试名称
26
/// </summary>
27
string TestName
{ get; set; }
28
#endregion
29
}
30
}
31
32
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。