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         }
 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         }

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏施炯的IoT开发专栏

转贴-WP7开发资源大收集

文章作者: jason huang 文章标签: Microsoft, Windows Phone 7, WP7 转贴链接: WP7开发资源大收集 这里收集...

1768
来自专栏Netkiller

DevOps Tools

DevOps Tools OS Software Configure Managment Install Ubuntu $ cd /usr/local/src/...

3234
来自专栏ml

nyoj-----284坦克大战(带权值的图搜索)

坦克大战 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 Many of us had played the game "Batt...

2805
来自专栏SAP最佳业务实践

SAP S/4 HANA新变化-COPA

Profitability Analysis The universal journal (ACDOCA) is the heart of Accounting...

36013
来自专栏SAP最佳业务实践

SAP S/4 HANA新变化-CO物料帐(for Ver.1610)

Material Ledger Actual Costing has been activated already in the system before t...

4245
来自专栏王磊的博客

经典面试题SALES TAXES思路分析和源码分享

题目: SALES TAXES Basic sales tax is applicable at a rate of 10% on all goods, ex...

2636
来自专栏ml

hdu 1561 The more, The Better (树上背包)

The more, The Better Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 327...

2898
来自专栏Golang语言社区

Golang生产级可靠UDP库

kcp-go is a Production-Grade Reliable-UDP library for golang.

892
来自专栏猿人谷

实用手册:130+ 提高开发效率的 vim 常用命令

  Vim 是从 vi 发展出来的一个文本编辑器。代码补完、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用。和 Emacs 并列成为类 Unix ...

1909
来自专栏小樱的经验随笔

Codeforces Round #395 (Div. 2)(A.思维,B,水)

A. Taymyr is calling you time limit per test:1 second memory limit per test:256 ...

2756

扫码关注云+社区