Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for running TSQL or non database-agnostic SQL functions. C…
…loses #2.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
' ___________________________________________________ | ||
' | ||
' © Hi-Integrity Systems 2010. All rights reserved. | ||
' www.hisystems.com.au - Toby Wicks | ||
' ___________________________________________________ | ||
' | ||
|
||
Option Strict On | ||
Option Explicit On | ||
|
||
Imports System.Linq | ||
|
||
Namespace SQL | ||
|
||
''' <summary> | ||
''' Allows an SQL function to utilised in a WHERE clause or as a calculated column. | ||
''' </summary> | ||
''' <remarks> | ||
''' Typically used to access a non database-agnostic function. | ||
''' </remarks> | ||
Public Class SQLFunctionExpression | ||
Inherits SQLExpression | ||
|
||
Private pstrFunctionName As String | ||
Private pobjFunctionArguments As SQLExpression() | ||
|
||
Public Sub New(strFunctionName As String) | ||
|
||
If String.IsNullOrEmpty(strFunctionName) Then | ||
Throw New ArgumentNullException | ||
End If | ||
|
||
pstrFunctionName = strFunctionName | ||
|
||
End Sub | ||
|
||
Public Sub New(strFunctionName As String, ParamArray arguments() As SQLExpression) | ||
|
||
Me.New(strFunctionName) | ||
|
||
pobjFunctionArguments = arguments | ||
|
||
End Sub | ||
|
||
Friend Overrides Function SQL(ByVal eConnectionType As Database.ConnectionType) As String | ||
|
||
Dim strArguments As String = String.Empty | ||
|
||
If pobjFunctionArguments IsNot Nothing Then | ||
strArguments = String.Join(", ", pobjFunctionArguments.Select(Function(argument) argument.SQL(eConnectionType)).ToArray) | ||
End If | ||
|
||
Return pstrFunctionName & "(" & strArguments & ")" | ||
|
||
End Function | ||
|
||
End Class | ||
|
||
End Namespace |