ningshuxia
2022-11-22 e0738c0754dd80a3b8d972f03d84b0611fd8254c
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
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
 
 
namespace IStation.DAL
{
    /// <summary>
    /// 物联卡缴费记录
    /// </summary>
    public partial class IotPaymentRecord : CorpDAL<Entity.IotPaymentRecord>
    {
        /// <summary>
        /// 
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.DefaultConnectionConfig; }
        }
 
        /// <summary>
        /// 通过 ProductID 获取
        /// </summary>
        public List<Entity.IotPaymentRecord> GetByProductID(long CorpID, long ProductID)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.IotPaymentRecord>().Where(x => x.CorpID == CorpID && x.ProductID == ProductID).ToList();
            }
        }
 
        /// <summary>
        /// 通过 ProductIds 获取
        /// </summary>
        public List<Entity.IotPaymentRecord> GetByProductIds(long CorpID, List<long> ProductIds)
        {
            if (ProductIds == null || ProductIds.Count < 1)
                return default;
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.IotPaymentRecord>().Where(x => x.CorpID == CorpID && ProductIds.Contains(x.ProductID)).ToList();
            }
        }
 
        /// <summary>
        /// 通过 BelongType 和 BelongID 获取
        /// </summary>
        public List<Entity.IotPaymentRecord> GetByBelongTypeAndBelongID(long CorpID, string BelongType, long BelongID)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.IotPaymentRecord, Entity.Product>((x, y) => x.ProductID == y.ID)
                    .Where((x, y) => y.CorpID == CorpID && y.BelongType == BelongType && y.BelongID == BelongID)
                    .Select(x => x).ToList();
            }
        }
 
 
    }
}