프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / Markus.Service.DataBase.Dapper / QueryParameters.cs @ d952e1d5

이력 | 보기 | 이력해설 | 다운로드 (3.18 KB)

1
using Dapper;
2
using System;
3
using System.Collections;
4
using System.Collections.Generic;
5
using System.Data;
6
using System.Linq;
7
using System.Text;
8
using System.Threading.Tasks;
9
using System.Linq.Expressions;
10
using System.Reflection;
11
using System.Reflection.Emit;
12
using System.ComponentModel;
13
using System.Data.SqlTypes;
14
using System.Dynamic;
15
using System.Globalization;
16
using System.Text.RegularExpressions;
17
using System.Diagnostics;
18

    
19
namespace Markus.Service.DataBase
20
{
21
    public partial class QueryParameters : SqlMapper.IDynamicParameters
22
    {
23
        DBMSType DBMS;
24

    
25
        public QueryParameters(DBMSType dbms)
26
        {
27
            DBMS = dbms;
28
        }
29

    
30
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
31
        ////////////////////////////////////////////////////////////////////////////////////////// Private
32

    
33
        #region Field
34

    
35
        /// <summary>
36
        /// 동적 매개 변수 목록
37
        /// </summary>
38
        private readonly DynamicParameters dynamicParameters = new DynamicParameters();
39

    
40
        /// <summary>
41
        /// 오라클 매개 변수 리스트
42
        /// </summary>
43
        private readonly List<Npgsql.NpgsqlParameter> NpgsqlParameterList = new List<Npgsql.NpgsqlParameter>();
44

    
45
        #endregion
46

    
47
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
48
        ////////////////////////////////////////////////////////////////////////////////////////// Public
49

    
50
        #region 추가하기 - Add(name, value, dbType, direction, size)
51

    
52
        /// <summary>
53
        /// 추가하기
54
        /// </summary>
55
        /// <param name="name">명칭</param>
56
        /// <param name="value">값</param>
57
        /// <param name="dbType">DB 타입</param>
58
        /// <param name="direction">방향</param>
59
        /// <param name="size">크기</param>
60
        public void Add(string name, object value = null, DbType? dbType = null, ParameterDirection? direction = null, int? size = null)
61
        {
62
            if (DBMS == DBMSType.MSSQL)
63
            {
64
                this.dynamicParameters.Add(name, value, dbType, direction, size);
65
            }
66
            else
67
            {
68
                Npgsql.NpgsqlParameter parameter = new Npgsql.NpgsqlParameter(parameterName: name, parameterType: dbType)
69
                {
70
                    Direction = direction.GetValueOrDefault()
71
                };
72

    
73
                this.NpgsqlParameterList.Add(parameter);
74
            }
75
        }
76

    
77
        #endregion
78
        #region 추가하기 - Add(name, oracleDbType, direction)
79

    
80
        /// <summary>
81
        /// 추가하기
82
        /// </summary>
83
        /// <param name="name">명칭</param>
84
        /// <param name="oracleDbType">오라클 DB 타입</param>
85
        /// <param name="direction">방향</param>
86
        public void Add(string name, NpgsqlTypes.NpgsqlDbType dbType, ParameterDirection direction)
87
        {
88
            Npgsql.NpgsqlParameter parameter = new Npgsql.NpgsqlParameter(parameterName: name, parameterType: dbType)
89
            {
90
                Direction = direction
91
            };
92

    
93
            this.NpgsqlParameterList.Add(parameter);
94
        }
95

    
96
        #endregion
97
    }
98
}
클립보드 이미지 추가 (최대 크기: 500 MB)