Dim dt As DataTable = catheter.FetchCatheter()
Dim ct As New EntityObjects.CatheterTypeBO
Dim cList As New List(Of EntityObjects.CatheterTypeBO)
For i As Integer = 0 To dt.Rows.Count - 1
ct.ID = dt.Rows(i)("ID")
ct.Type = dt.Rows(i)("CTYPE")
ct.Active = dt.Rows(i)("ACTIVE").ToString()
cList.Add(ct)
Next
通过dt的最后一行更新cList的所有索引。需要将数据表转换为List
答案 0 :(得分:0)
尝试使用AsEnumerable
,然后使用Last()
,如:
Dim dt As DataTable = catheter.FetchCatheter()
Dim ct As New EntityObjects.CatheterTypeBO
Dim cList As New List(Of EntityObjects.CatheterTypeBO)
Dim dr as DataRow = dt.AsEnumerable().Last()
ct.ID = dr("ID")
ct.Type = dr("CTYPE")
ct.Active = dr("ACTIVE").ToString()
cList.Add(ct)