Generic Lists to Datasets

Easy way to push a Generic List into a Dataset
** Note 'tasks' is the name of my generic list class

Public Function ConvertGenericsListToDataSet(ByVal listvalue As tasks()) As DataSet

Dim sb As New StringBuilder()
Dim xmlSerializer As New XmlSerializer(GetType(tasks()))
Dim sw As New StringWriter(sb)
xmlSerializer.Serialize(sw, listvalue)
Dim stream As New StringReader(sb.ToString())
Dim ds As New DataSet()
ds.ReadXml(stream)

Return ds

End Function

Comments

Popular posts from this blog

Linq Exclude from separate list

Sorting Ascending and Descending

Linq Query Syntax vs Method Syntax