不确定是否有一个“正确的”答案,所以我已经标记为社区维基。为长时间的前导而道歉。表模块/表网关 - 从网关加载代码的位置?
我在.Net中构建了一个规模适中的Web应用程序,并且已经建立在基于表的架构上。我的DAL层由一组处理加载/保存数据到数据库的TableGateway类组成 - 它们返回强类型的数据集。应用程序逻辑被组织成一组TableModule类。最后,我的ASPX页面处理显示内容并将表单值传递给要处理的TableModule。
让我困惑的是谁应该负责调用TableGateway来获取DataSet,ASPX代码隐藏或TableModule?
实施例1 - ASPX做的:
SomePage.aspx.cs:
protected void AddLink_Click(object sender, EventArgs args)
{
long id = long.Parse(PopulationDropDown.SelectedValue);
string someProperty = SomePropertyTextBox.Text;
IPopulationGateway populationGateway = DALServicesLocator.GetPopulationGateway();
PopulationDataSet populationData = populationGateway.LoadPopulationDetails(id);
PopulationModule.SomeLogicToAddStuff(populationData, id, someProperty);
populationGateway.Save(populationData);
}
实施例2 - TableModule做的:
SomePage.aspx.cs:
protected void AddLink_Click(object sender, EventArgs args)
{
long id = long.Parse(PopulationDropDown.SelectedValue);
string someProperty = SomePropertyTextBox.Text;
// Just pass values to the TableModule and let it talk to the Gateway.
PopulationModule.SomeLogicToAddStuff(id, someProperty);
}
我很欣赏这是一个在宏伟计划中的争议问题,但它真的让我烦恼! – rob 2009-12-22 16:30:03