在.NET 3.5 平台上使用LINQ to SQL创建三层/多层Web应用系统 (Part 4)

导读:
   在.NET 3.5 平台上使用LINQ to SQL创建三层/多层Web应用系统 (Part 4)
  构建业务外观层(Business Facade Layer)
  所有业务逻辑将在这一层实现。一般而言,这一层负责处理数据和在表现层与数据访问层之间传递数据。这一层从物理上提供上层接口隔离表现层代码和数据访问层代码,ASP.NET页面不能直接与数据访问层交互。相反,页面应该调用业务外观层的方法。图3.1 展示了业务外观层的详细视图。
  
  
  图3.1:业务外观层-详细视图
  
  在我们的示例程序中,业务外观层仅仅包含一个组件-BFLCustomer。示例代码如下:
   代码片段1.2 :业务外观层
  usingSystem;
  usingSystem.Collections.Generic;
  usingSystem.Linq;
  usingSystem.Text;
  usingDataAccess;
  usingSystem.Data.Linq;
  usingDataLinq;
  
  namespaceBusinessFacade
  {
  publicclassBFLCustomer
  {
  privateDALCustomerobjDataAccess = newDALCustomer();
  
  publicTable SelectRecordAll()
  {
  returnobjDataAccess.SelectRecordAll();
  }
  
  publicCustomerSelectRecordByID(stringcustomerID)
  {
  returnobjDataAccess.SelectRecordByID(customerID);
  }
  
  publicList SelectRecordByIDListable(stringcustomerID)
  {
  returnobjDataAccess.SelectRecordByIDListable(customerID);
  }
  
  publicstringInsertRecord(CustomerlocalTable)
  {
  returnobjDataAccess.InsertRecord(localTable);
  }
  
  publicvoidUpdateRecord(CustomerlocalTable)
  {
  objDataAccess.UpdateRecord(localTable);
  }
  
  publicvoidDeleteRecord(stringcustomerID)
  {
  objDataAccess.DeleteRecord(customerID);
  }
  
  publicTable SelectAllOrder()
  {
  returnobjDataAccess.SelectAllOrder();
  }
  
  publicTable SelectAllOrderDetail()
  {
  returnobjDataAccess.SelectAllOrderDetail();
  }
  }
  }
  
  BFLCustomer 组件包括下面类图所示的公共方法列表,这些方法用来与数据访问层交换。
  注:业务外观层没有创建DataContext类的实例,因此它不能够实现任何数据访问逻辑。
  BFLCustomer 组件的类图如下:
  
  
  图3.2:业务外观层 – 类图
  EntLib.com开源小组注:本文翻译《Building Multi-Tier Web Application in .NET 3.5 Framework Using LINQ to SQL》。后面内容待续。欢迎交流LINQ相关技术。
  上几篇文章:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值