N
Nikolay Petrov
I am searching for an idea how to optimize some of my code.
Let's say I have a class, which exposes some properties:
Class Dummy1
Private m_sValue1 As String
Private m_sValue2 As String
Public Property Value1() As String
Get
Value1 = Me.m_sValue1
End Get
Set(ByVal Value As String)
Me.m_sValue1 = Value
End Set
End Property
Public Property Value2() As String
Get
Value1 = Me.m_sValue2
End Get
Set(ByVal Value As String)
Me.m_sValue2 = Value
End Set
End Property
End Class
I have second class, one of who's methods returns an array of the
previus Class. Also I have second method, which returns the same array,
but this time in dataset. I create this dataset and it's datatable from
code:
Public Function GetDumies2() As System.Data.DataSet
Dim RetVal As New System.Data.DataSet("DummyDS")
Dim dT As New System.Data.DataTable("Dummies")
Dim dCol As System.Data.DataColumn
dCol = New System.Data.DataColumn("Value1") '0
dCol.DataType = System.Type.GetType("System.String")
dT.Columns.Add(dCol)
dCol = New System.Data.DataColumn("Value2") '0
dCol.DataType = System.Type.GetType("System.String")
dT.Columns.Add(dCol)
Dim tmpVal As Dummy1()
tmpVal = Me.GetDumies
Dim i As Integer
For i = 0 To tmpVal.GetUpperBound(0)
Dim dR As System.Data.DataRow
dR = dT.NewRow
dR.Item("Value1") = tmpVal(i).Value1
dR.Item("Value2") = tmpVal(i).Value2
dT.Rows.Add(dR)
Next
RetVal.Tables.Add(dT)
RetVal.AcceptChanges()
Return RetVal
End Function
My exact question is, how to optimize the generation of the DataSet and
DataTable? I do this in many classes, and providing its properties in
the generation of the dataset has many cons.
Thanks in advance
Let's say I have a class, which exposes some properties:
Class Dummy1
Private m_sValue1 As String
Private m_sValue2 As String
Public Property Value1() As String
Get
Value1 = Me.m_sValue1
End Get
Set(ByVal Value As String)
Me.m_sValue1 = Value
End Set
End Property
Public Property Value2() As String
Get
Value1 = Me.m_sValue2
End Get
Set(ByVal Value As String)
Me.m_sValue2 = Value
End Set
End Property
End Class
I have second class, one of who's methods returns an array of the
previus Class. Also I have second method, which returns the same array,
but this time in dataset. I create this dataset and it's datatable from
code:
Public Function GetDumies2() As System.Data.DataSet
Dim RetVal As New System.Data.DataSet("DummyDS")
Dim dT As New System.Data.DataTable("Dummies")
Dim dCol As System.Data.DataColumn
dCol = New System.Data.DataColumn("Value1") '0
dCol.DataType = System.Type.GetType("System.String")
dT.Columns.Add(dCol)
dCol = New System.Data.DataColumn("Value2") '0
dCol.DataType = System.Type.GetType("System.String")
dT.Columns.Add(dCol)
Dim tmpVal As Dummy1()
tmpVal = Me.GetDumies
Dim i As Integer
For i = 0 To tmpVal.GetUpperBound(0)
Dim dR As System.Data.DataRow
dR = dT.NewRow
dR.Item("Value1") = tmpVal(i).Value1
dR.Item("Value2") = tmpVal(i).Value2
dT.Rows.Add(dR)
Next
RetVal.Tables.Add(dT)
RetVal.AcceptChanges()
Return RetVal
End Function
My exact question is, how to optimize the generation of the DataSet and
DataTable? I do this in many classes, and providing its properties in
the generation of the dataset has many cons.
Thanks in advance