3939'* 2013/07/07 西野 大介 ExecGenerateSQL(SQL生成)メソッド(実行しない)を追加
4040'* 2014/11/20 Sandeep Implemented CommandTimeout property and SetCommandTimeout method.
4141'* 2014/11/20 Sai removed IDbCommand property in SetCommandTimeout method.
42+ '* 2018/08/07 西野 大介 ストアド実行のためCommandType.StoredProcedureを設定可能に。
4243'**********************************************************************************
4344
45+ Imports System
46+ Imports System.Data
47+ Imports System.Collections.Generic
48+
4449Imports Touryo.Infrastructure.Business.Exceptions
4550Imports Touryo.Infrastructure.Framework.Exceptions
4651Imports Touryo.Infrastructure.Public.Db
@@ -52,6 +57,9 @@ Namespace Touryo.Infrastructure.Business.Dao
5257 Inherits MyBaseDao
5358 # Region "インスタンス変数"
5459
60+ ''' <summary>CommandType</summary>
61+ Private _cmdType As System.Nullable( Of CommandType) = Nothing
62+
5563 # Region "パラメタ"
5664
5765 ''' <summary>ユーザ パラメタ(文字列置換)用ディクショナリ</summary>
@@ -60,12 +68,14 @@ Namespace Touryo.Infrastructure.Business.Dao
6068 ''' <summary>パラメタ ライズド クエリのパラメタ用ディクショナリ</summary>
6169 Private DicParameter As New Dictionary( Of String , Object )()
6270
71+ # Region "追加のDictionary"
6372 ''' <summary>パラメタ ライズド クエリの指定されたパラメータ(の型)を保持するディクショナリ</summary>
6473 Private DicParameterType As New Dictionary( Of String , Object )()
6574 ''' <summary>パラメタ ライズド クエリの指定されたパラメータ(のサイズ)を保持するディクショナリ</summary>
6675 Private DicParameterSize As New Dictionary( Of String , Integer )()
6776 ''' <summary>パラメタ ライズド クエリの指定されたパラメータ(の方向)を保持するディクショナリ</summary>
6877 Private DicParameterDirection As New Dictionary( Of String , ParameterDirection)()
78+ # End Region
6979
7080 # End Region
7181
@@ -216,7 +226,7 @@ Namespace Touryo.Infrastructure.Business.Dao
216226 ''' <summary>CommandTimeout</summary>
217227 ''' <remarks>自由に(拡張して)利用できる。</remarks>
218228 Public WriteOnly Property CommandTimeout() As Integer
219- Set (value As Integer )
229+ Set
220230 Me ._commandTimeout = value
221231 End Set
222232 End Property
@@ -235,6 +245,13 @@ Namespace Touryo.Infrastructure.Business.Dao
235245 MyBase .New(dam)
236246 End Sub
237247
248+ ''' <summary>コンストラクタ</summary>
249+ ''' <remarks>自由に利用できる。</remarks>
250+ Public Sub New (dam As BaseDam, cmdType As CommandType)
251+ MyBase .New(dam)
252+ Me ._cmdType = cmdType
253+ End Sub
254+
238255 # End Region
239256
240257 # Region "クエリ メソッド"
@@ -246,10 +263,10 @@ Namespace Touryo.Infrastructure.Business.Dao
246263 ''' <remarks>自由に(拡張して)利用できる。</remarks>
247264 Public Shadows Function ExecSelectScalar() As Object
248265 ' SQLの設定
249- Me .SetSQL()
266+ Me .SetSQL()
250267
251- ' To Set CommandTimeout
252- Me .SetCommandTimeout()
268+ ' Set CommandTimeout
269+ Me .SetCommandTimeout()
253270
254271 ' パラメタの一括設定
255272 Me .SetParameters()
@@ -264,10 +281,10 @@ Namespace Touryo.Infrastructure.Business.Dao
264281 ''' <remarks>自由に(拡張して)利用できる。</remarks>
265282 Public Shadows Sub ExecSelectFill_DT(dt As DataTable)
266283 ' SQLの設定
267- Me .SetSQL()
284+ Me .SetSQL()
268285
269- ' To Set CommandTimeout
270- Me .SetCommandTimeout()
286+ ' Set CommandTimeout
287+ Me .SetCommandTimeout()
271288
272289 ' パラメタの一括設定
273290 Me .SetParameters()
@@ -282,10 +299,10 @@ Namespace Touryo.Infrastructure.Business.Dao
282299 ''' <remarks>自由に(拡張して)利用できる。</remarks>
283300 Public Shadows Sub ExecSelectFill_DS(ds As DataSet)
284301 ' SQLの設定
285- Me .SetSQL()
302+ Me .SetSQL()
286303
287- ' To Set CommandTimeout
288- Me .SetCommandTimeout()
304+ ' Set CommandTimeout
305+ Me .SetCommandTimeout()
289306
290307 ' パラメタの一括設定
291308 Me .SetParameters()
@@ -300,10 +317,10 @@ Namespace Touryo.Infrastructure.Business.Dao
300317 ''' <remarks>自由に(拡張して)利用できる。</remarks>
301318 Public Shadows Function ExecSelect_DR() As IDataReader
302319 ' SQLの設定
303- Me .SetSQL()
320+ Me .SetSQL()
304321
305- ' To Set CommandTimeout
306- Me .SetCommandTimeout()
322+ ' Set CommandTimeout
323+ Me .SetCommandTimeout()
307324
308325 ' パラメタの一括設定
309326 Me .SetParameters()
@@ -318,10 +335,10 @@ Namespace Touryo.Infrastructure.Business.Dao
318335 ''' <remarks>自由に(拡張して)利用できる。</remarks>
319336 Public Shadows Function ExecInsUpDel_NonQuery() As Integer
320337 ' SQLの設定
321- Me .SetSQL()
338+ Me .SetSQL()
322339
323- ' To Set CommandTimeout
324- Me .SetCommandTimeout()
340+ ' Set CommandTimeout
341+ Me .SetCommandTimeout()
325342
326343 ' パラメタの一括設定
327344 Me .SetParameters()
@@ -337,10 +354,10 @@ Namespace Touryo.Infrastructure.Business.Dao
337354 ''' <remarks>自由に(拡張して)利用できる。</remarks>
338355 Public Shadows Function ExecGenerateSQL(sqlUtil As SQLUtility) As String
339356 ' SQLの設定
340- Me .SetSQL()
357+ Me .SetSQL()
341358
342- ' To Set CommandTimeout
343- Me .SetCommandTimeout()
359+ ' Set CommandTimeout
360+ Me .SetCommandTimeout()
344361
345362 ' パラメタの一括設定
346363 Me .SetParameters()
@@ -359,24 +376,33 @@ Namespace Touryo.Infrastructure.Business.Dao
359376 ' SQL指定
360377 If Me ._sQLFileName <> "" Then
361378 ' ファイルから
362- Me .SetSqlByFile2( Me ._sQLFileName)
379+ If Me ._cmdType.HasValue Then
380+ Me .SetSqlByFile2( Me ._sQLFileName, Me ._cmdType.Value)
381+ Else
382+ Me .SetSqlByFile2( Me ._sQLFileName)
383+ End If
363384 ElseIf Me ._sQLText <> "" Then
364385 ' テキストから
365- Me .SetSqlByCommand( Me ._sQLText)
386+ If Me ._cmdType.HasValue Then
387+ Me .SetSqlByCommand( Me ._sQLText, Me ._cmdType.Value)
388+ Else
389+ Me .SetSqlByCommand( Me ._sQLText)
390+
391+ End If
366392 Else
367393 ' SQLエラー
368394 Throw New BusinessSystemException(MyBusinessSystemExceptionMessage.CMN_DAO_ERROR( 0 ), [String].Format(MyBusinessSystemExceptionMessage.CMN_DAO_ERROR( 1 ), MyBusinessSystemExceptionMessage.CMN_DAO_ERROR_SQL))
369395 End If
370- End Sub
371-
372- ''' <summary>To Set CommandTimeout</summary>
373- Private Sub SetCommandTimeout()
374- ' If CommandTimeout is >= 0 then set CommandTimeout.
375- ' Else skip, automatically it will set default CommandTimeout.
376- If Me ._commandTimeout >= 0 Then
377- Me .GetDam().DamIDbCommand.CommandTimeout = Me ._commandTimeout
378- End If
379- End Sub
396+ End Sub
397+
398+ ''' <summary>To Set CommandTimeout</summary>
399+ Private Sub SetCommandTimeout()
400+ ' If CommandTimeout is >= 0 then set CommandTimeout.
401+ ' Else skip, automatically it will set default CommandTimeout.
402+ If Me ._commandTimeout >= 0 Then
403+ Me .GetDam().DamIDbCommand.CommandTimeout = Me ._commandTimeout
404+ End If
405+ End Sub
380406
381407 ''' <summary>パラメタの一括設定(内部用)</summary>
382408 Private Sub SetParameters()
0 commit comments