ningshuxia
2024-06-24 5d674c809bf51b77ddd31a365bcfcfe12b35c556
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
namespace IStation.DAL.SQLite
{
    /// <summary>
    /// 
    /// </summary>
    public partial class HydraulicModelRecord : IHydraulicModelRecord
    {
        /// <summary>
        /// 
        /// </summary>
        public ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.HydraulicConnectionConfig; }
 
        }
 
        /// <summary>
        /// 批量插入
        /// </summary> 
        public bool Inserts(List<Entity.HydraulicModelRecord> list)
        {
            if (list == null || list.Count < 1)
            {
                return false;
            }
 
            using (SqlSugarClient sqlSugarClient = new SqlSugarClient(ConnectionConfig))
            {
                return sqlSugarClient.Insertable(list).ExecuteCommand() > 0;
            }
        }
 
        /// <summary>
        /// 大批量插入
        /// </summary> 
        public bool BulkInserts(List<Entity.HydraulicModelRecord> list)
        {
            if (list == null || list.Count < 1)
            {
                return false;
            }
 
            using (SqlSugarClient sqlSugarClient = new SqlSugarClient(ConnectionConfig))
            {
                return sqlSugarClient.Fastest<Entity.HydraulicModelRecord>().BulkCopy(list) > 0;
            }
        }
 
 
        /// <summary>
        /// 删除全部
        /// </summary> 
        public bool DeleteAll()
        {
            using (SqlSugarClient sqlSugarClient = new SqlSugarClient(ConnectionConfig))
            {
                return sqlSugarClient.DbMaintenance.TruncateTable<Entity.HydraulicModelRecord>();
            }
        }
 
 
        /// <summary>
        /// 查询全部
        /// </summary>
        /// <returns></returns>
        public List<Entity.HydraulicModelRecord> GetAll()
        {
            using (SqlSugarClient sqlSugarClient = new SqlSugarClient(ConnectionConfig))
            {
                return sqlSugarClient.Queryable<Entity.HydraulicModelRecord>().ToList();
            }
        }
 
        /// <summary>
        /// 根据时间查询
        /// </summary>
        /// <returns></returns>
        public List<Entity.HydraulicModelRecord> GetByDate(DateTime start, DateTime end)
        {
            using (SqlSugarClient sqlSugarClient = new SqlSugarClient(ConnectionConfig))
            {
                return sqlSugarClient.Queryable<Entity.HydraulicModelRecord>().Where(x => x.Time >= start && x.Time <= end).ToList();
            }
        }
 
    }
}