Forum Discussion
TT
2 years agoNew Contributor III
Reading dictionary type
I am using below sql to get validation messages from the workflow transformation process to be used in Transformation Event Handler. But, I need to put the output of this dictionary into a flat file...
aformenti
OneStream Employee
2 years agoHI TT,
This snippet should give you what you need:
#Region "Dictionary To DataTable"
'------------------------------------------------------------------------------------------------------------
'Referenced Code: DictionaryToDataTable -> DataTable
'
'Description: Converts Dictionary(Of String, String) to DataTable from Dictionary where column = Key and row = Value
'
'Notes:
'
'Usage:
'
'Created By: OneStream
'Date Created: 04-04-2023
'------------------------------------------------------------------------------------------------------------
Public Function DictionaryToDataTable(ByVal si As SessionInfo, ByVal dictParam As Dictionary(Of String, String)) As DataTable
' Method name
Dim methodName As String = System.Reflection.MethodInfo.GetCurrentMethod().Name
' Object to return
Dim dt As New DataTable()
Try
' Add columns (Keys)
dt.Columns.AddRange(dictParam.Keys.ToList().Select(Function(lambda) New DataColumn(lambda, GetType(String))).ToArray())
' Add row (Values)
dt.Rows.Add(dictParam.Values.ToArray())
' Return
Return dt
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(ex))
End Try
End Function
#End Region
Related Content
- 4 years ago
- 2 years ago
- 2 years ago
- 4 years ago
- 2 years ago