schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using DataEntity.Device;
using DataEntity.Page;
using DataRWDAL.Base;
using SqlSugar;
using System;
using System.Collections.Generic;
using XCommon.SqlSugar;
 
namespace DataRWDAL.Device
{
    public class DeviceConfigMethodDB : BaseDB
    {
        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="pagination"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public static Tuple<List<DeviceConfigMethodModel>, int> GetPageData(Pagination pagination, DeviceConfigMethodModel condition)
        {
            using (var db = GetInstance())
            {
                var whereExpression = LinqExtensions.True<DeviceConfigMethodModel>();
                whereExpression = whereExpression.And(it => it.DeviceconfigId.Equals(condition.DeviceconfigId));
 
                if (!string.IsNullOrEmpty(condition.ParameterName))
                {
                    whereExpression = whereExpression.And(it => it.ParameterName.Contains(condition.ParameterName));
                }
                // u => u.Sort
                return GetPage<DeviceConfigMethodModel>(pagination, whereExpression, null, OrderByType.Asc);
            }
        }
 
        /// <summary>
        /// 根据设备方法Id,获取设备方法信息
        /// </summary>
        /// <param name="methodId"></param>
        /// <returns></returns>
        public static DeviceConfigMethodModel GetInfodById(string methodId)
        {
            using (var db = GetInstance())
            {
                return db.Queryable<DeviceConfigMethodModel>().Single(it => it.Id.Equals(methodId));
            }
        }
 
        /// <summary>
        /// 获取设备方法信息
        /// </summary>
        /// <param name="deviceconfigId"></param>
        /// <param name="parameterName"></param>
        /// <returns></returns>
        public static List<DeviceConfigMethodModel> GetInfo(string deviceconfigId, string parameterName)
        {
            using (var db = GetInstance())
            {
                return db.Queryable<DeviceConfigMethodModel>().Where(it => it.DeviceconfigId.Equals(deviceconfigId) && it.ParameterName.Equals(parameterName)).ToList();
            }
        }
 
        /// <summary>
        /// 登录设备方法信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Add(DeviceConfigMethodModel model)
        {
            using (var db = GetInstance())
            {
                return db.Insertable<DeviceConfigMethodModel>(model).ExecuteCommand();
            }
        }
 
        /// <summary>
        /// 更新设备方法信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Update(DeviceConfigMethodModel model)
        {
            using (var db = GetInstance())
            {
                return db.Updateable<DeviceConfigMethodModel>(model).ExecuteCommand();
            }
        }
 
        /// <summary>
        /// 删除设备方法信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int DelById(DeviceConfigMethodModel model)
        {
            using (var db = GetInstance())
            {
                return db.Deleteable<DeviceConfigMethodModel>(model).ExecuteCommand();
            }
        }
 
        /// <summary>
        /// 获取设备方法列表
        /// </summary>
        /// <returns></returns>
        public static List<DeviceConfigMethodModel> GetListByDeviceconfigId(string deviceconfigId)
        {
            using (var db = GetInstance())
            {
                return db.Queryable<DeviceConfigMethodModel>().Where(it=>it.DeviceconfigId.Equals(deviceconfigId)).ToList();
            }
        }
 
        /// <summary>
        /// 获取设备方法列表
        /// </summary>
        /// <returns></returns>
        public static List<DeviceConfigMethodModel> GetDeviceConfigMethodList()
        {
            using (var db = GetInstance())
            {
                return db.Queryable<DeviceConfigMethodModel>().OrderBy(it => it.CreateTime, OrderByType.Desc).ToList();
            }
        }      
    }
}