zoukankan      html  css  js  c++  java
  • ORM框架(ITDOS实战源码)

     ORM提供了实现持久化层的另一种模式,它采用映射元数据来描述对象关系的映射,使得ORM中间件能在任何一个应用的业务逻辑层和数据库层之间充当桥梁。

    如以下示例:

     1  public int GetSystemAccreditMessageInfo(AccreditParam param)
     2         {
     3             var where = new Where<User>();
     4             var countMesage = 0;//记录提醒次数
     5             HttpCookie cookie = HttpContext.Current.Request.Cookies["UserLogin"] as HttpCookie;
     6             if (cookie["Login_id"] != null)
     7             {
     8                 where.And(d => d.id == cookie["Login_id"].ToString());
     9             }
    10             where.And(d => d.Del_state == 0);
    11             var fs = DB.Context.From<User>()
    12                 .Select(User._.All, Power._.All)
    13                 .InnerJoin<Power>((a, b) => a.Role_id == b.id)
    14                 .Where(where);
    15             if (fs.First().Authority == "0")
    16             {
    17                 countMesage = 0;
    18             }
    19             else if (fs.First().Authority == "1")
    20             {
    21                 countMesage = DB.Context.From<Accredit>().Where(d => d.OAuditor_signature == null || d.OAuditor_signature == "").Count();
    22             }
    23             else if (fs.First().Authority == "2")
    24             {
    25                 countMesage = DB.Context.From<Accredit>().Where(d => d.TAuditor_signature == null || d.TAuditor_signature == "").Count();
    26             }
    27             else if (fs.First().Authority == "3")
    28             {
    29                 countMesage = DB.Context.From<Accredit>().Where(d => d.OAuditor_signature == null || d.OAuditor_signature == "" || d.TAuditor_signature == null || d.TAuditor_signature == "").Count();
    30             }
    31             return countMesage;
    32         }
    AccreditLogic.cs
     1 public BaseResult AddAccreditInfo(AccreditParam param)
     2         {
     3             var model = new Accredit();
     4             model.id = Guid.NewGuid().ToString();
     5             model.Acceptance_number = param.Acceptance_number;
     6             model.Certificate_number = param.Certificate_number;
     7             model.Issuing_office = param.Issuing_office;
     8             model.Issue_date = param.Issue_date;
     9             model.Effective_date = param.Effective_date;
    10             model.Authorization_projectname = param.Authorization_projectname;
    11             model.Measuring_range = param.Measuring_range;
    12             model.Accuracy = param.Accuracy;
    13             model.Organization_name = param.Organization_name;
    14             model.Address = param.Address;
    15             model.Corporate_representative = param.Corporate_representative;
    16             model.Leading_person = param.Leading_person;
    17             model.Competent_department = param.Competent_department;
    18             model.Authorized_area = param.Authorized_area;
    19             model.Authorization_form = param.Authorization_form;
    20             model.Approver = param.Approver;
    21             model.Input_person = param.Input_person;
    22             model.Input_unit = param.Input_unit;
    23             model.Acceptance_date = param.Acceptance_date;
    24             HttpCookie cookie = HttpContext.Current.Request.Cookies["UserLogin"] as HttpCookie;
    25             if (cookie["OrgId"] != null)
    26             {
    27                 model.OrgId = cookie["OrgId"].ToString();
    28             }
    29             if (cookie["OrgId"]=="63001c38-afa4-4a06-567d-0f39b6b5ca9b")
    30             {
    31                 model.Processing_state = 0;
    32             }
    33             model.Remarks = param.Remarks;
    34             model.Del_state = 0;
    35             model.Time = DateTime.Now;
    36             //model.Processing_state = param.Processing_state;
    37             model.brand = param.brand;
    38             var count = DB.Context.Insert<Accredit>(model);
    39             return new BaseResult(true, model, "", count);
    40         }
     1  public BaseResult UptAccreditInfo(AccreditParam param)
     2         {
     3             var result = GetUpdateModel(param);
     4             if (!result.IsSuccess)
     5                 return result;
     6 
     7             var model = (Accredit)result.Data;
     8             model.Acceptance_number = param.Acceptance_number;
     9             model.Certificate_number = param.Certificate_number;
    10             model.Issuing_office = param.Issuing_office;
    11             model.Issue_date = param.Issue_date;
    12             model.Effective_date = param.Effective_date;
    13             model.Authorization_projectname = param.Authorization_projectname;
    14             model.Measuring_range = param.Measuring_range;
    15             model.Accuracy = param.Accuracy;
    16             model.Organization_name = param.Organization_name;
    17             model.Address = param.Address;
    18             model.Corporate_representative = param.Corporate_representative;
    19             model.Leading_person = param.Leading_person;
    20             model.Competent_department = param.Competent_department;
    21             model.Authorized_area = param.Authorized_area;
    22             model.Authorization_form = param.Authorization_form;
    23             model.Approver = param.Approver;
    24             model.Input_person = param.Input_person;
    25             model.Input_unit = param.Input_unit;
    26             HttpCookie cookie = HttpContext.Current.Request.Cookies["UserLogin"] as HttpCookie;
    27             if (cookie["OrgId"] != null)
    28             {
    29                 model.OrgId = cookie["OrgId"].ToString();
    30             }
    31             if (cookie["OrgId"] == "63001c38-afa4-4a06-567d-0f39b6b5ca9b")
    32             {
    33                 model.Processing_state = 0;
    34             }
    35             model.Acceptance_date = param.Acceptance_date;
    36             model.Remarks = param.Remarks;
    37             model.Del_state = 0;
    38             //model.Processing_state = param.Processing_state??model.Processing_state;
    39             model.Time = DateTime.Now;
    40             model.brand = param.brand;
    41             var count = DB.Context.Update(model, d => d.id == param.id);
    42             return new BaseResult(true, model, "", count);
    43         }
    AccreditLogic.cs
  • 相关阅读:
    Python爬虫学习遇到的问题
    爬取网页内容后写入文件报错UnicodeEncodeError: 'gbk' codec can't encode的问题解决方案
    第14.6节 使用Python urllib.request模拟浏览器访问网页的实现代码
    Mina源码阅读笔记(一)-整体解读
    使用异步 I/O 大大提高应用程序的性能
    同步和异步,阻塞和非阻塞
    位运算详解
    php引用传值详解
    PHP获取指定地区的天气
    新闻网站开发-手机端-基于Wordpress
  • 原文地址:https://www.cnblogs.com/cykj/p/ORMIFrame-ITDOS-Coder.html
Copyright © 2011-2022 走看看