zoukankan      html  css  js  c++  java
  • 关于三层架构

    三层架构解析:http://blog.csdn.net/hanxuemin12345/article/details/8544957/

    1、功能分析(点击按钮让表中的字段id=3的年龄+1

    2、根据功能确定SQL语句(update student set age=student.age+1 where id=3

    3、在数据访问层(DAL)编写执行该SQL语句的方法。编写前,确定该方法的参数与返回值。(DAL层的名字与表明相同 StudentDAL

    4、编写业务逻辑层的方法(StudentBLL / StudentService),确定该方法的参数与返回值(返回值取决于UI层需要用什么样的返回值

    5、编写UI层代码

      5.1、采集数据

      5.2、展示数据

      5.3、调用对应的业务逻辑层来实现具体功能

        5.3.1、实例化BLL层类

        5.3.2、调用BLL中的方法 

    出了DAL层,BLL层拿到的数据类型,必须为强类型的。(DataTable就是弱类型的,实体Model就是强类型的)

    public User GetInfoById(string id){
         User u=null;
       //List<User> UList=new List<User>();                    
       if(sqlHelper执行的结果){
           //将值赋给User的实例
           u=new User;
           u.name=xxx;
           u.age=xxx;
           u.sex=xxx;
        }  
        return u;
    }    
    DAL中的代码片段

    DAL中返回的对象:

      若是一个集合类型的时候,当执行结果为空的时候(select语句执行得到的结果为null),那么就返回一个长度为0的list。

      若是一个model,     当执行结果为空的时候(select语句执行得到的结果为null),那么就返回一个null。

    public class Student {
            public int ID { get; set; }
            public string Name { get; set; }
            public int Age { get; set; }
            public string Sex { get; set; }
    
            public Score FenShu { get; set; }
        }
    
    public class Score {
            public int Chinese { get; set; }
            public int Math { get; set; }
            public int English { get; set; }
            public int SID { get; set; }
        }
    在实体中体现表的主从关系

     

    Heima8.OA.BLL
    
    Heima8.OA.Common
    
    Heima8.OA.EFDAL
    
    Heima8.OA.Model
    
    Heima8.OA.UI.Portal
    
    Heima8.OA.UnitTest
    类库名称
  • 相关阅读:
    BC高精确度函数使用。
    thinkPHP中_initialize方法实例分析
    MySQL中concat函数
    使用docker打造spark集群
    zhihu spark集群,书籍,论文
    Windows下安装使用curl命令
    数据可视化的优秀入门书籍有哪些,D3.js 学习资源汇总
    2015互联网+影响力报告发布
    The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
    centos linux中怎么查看和修改计算机名/etc/sysconfig/network
  • 原文地址:https://www.cnblogs.com/vichin/p/7943310.html
Copyright © 2011-2022 走看看