13,189
社区成员
发帖
与我相关
我的任务
分享

使用委托就可以了:
BLL中:
C# code
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace BLL
{
public class Test
{
public delegate void RefreshDelegate(ref string msg);
public void Call(RefreshDelegate d)
{
string msg = string.Empty;
for (int i = 1; i <= 10; i++)
{
msg = string.Format("{0}\r\n", i);
d(ref msg);
}
}
}
}
UI层:
C# code
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace CSWin
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void btn_Test_Click(object sender, EventArgs e)
{
BLL.Test test = new BLL.Test();
BLL.Test.RefreshDelegate d = new BLL.Test.RefreshDelegate(Refresh);
test.Call(d);
}
private void Refresh(ref string msg)
{
this.textBox1.Text += msg;
}
}
}
思路B:
因对大项目架构经验欠缺,若基础就有所问题,请各位指出.谢谢
分析:
A方法
------
清晰,但是涉及到如上面所术的问题,实体现在不在单单是数据库类,加入一些映射关系,但是之前的编写方法是在实体类中调用函数操作DAL获取对象.
看到上面朋友们的回答总结:
1.实体类 为对象为纯粹的传输载体,不可以操作DAL BLL的操作
2.如果要建立实体类的主外类关系映射需要在BLL建立
解决办法
1.使用类EF的ORM工具,但在项目中已经使用tt模板生成了 增删改查模板,只需要小巧的映射关系获取关联对象即可,该如何选择?
2.使用BLL层关联父子类关系,这样会大大加重代码量,并且有业务调用仅需要流程主表数据即可,有些业务需要流程主表信息及相关操作日志,那该如何处理
B方法
----------
B方法,操作相对灵活,因DAL 和 实体层 合并,其中编写内容可以相互操作,但缺点是BLL UI 层需要实体层的时候直接将DAL也引入了项目
总结
陷入迷乱...
正解,估计是被代码生成器给套住了[/quote]public class A
{
public string Field_1{get;set;}
public int Field_2{get;set;}
public B[ ] Field_3{get;set;}
} 这类失血模型,不但 Model 不可能与数据库引擎关系,也不可能与业务功能操作有关系。