Dim lstEpdObj As New List(Of ExpandoObject)
Dim DynColumns As Integer = 10 'สร้าง 10 Columns
For r As Integer = 0 To 200000 'สร้าง 2 แสนระเบียน (Rows)
Dim epdObj As New ExpandoObject()
Dim p = TryCast(epdObj, IDictionary(Of String, Object))
For c As Integer = 0 To DynColumns - 1
p("dynColumn" & c) = "dynValue-" & r & c
Next
lstEpdObj.Add(epdObj)
Next
'แปลง Dynamic Object ให้เป็น DataTable ที่เราเราท่านท่านคุ้นเคยกัน
Dim lst = lstEpdObj.Cast(Of IDictionary(Of String, Object))()
If (Not lst.Any()) Then
Dim dtTemp As New DataTable()
lst.First().Keys.ForEach(Function(c) dtTemp.Columns.Add(c)) 'สร้างคอลัมภ์ (10 Columns)
lst.ForEach(Sub(r) dtTemp.Rows.Add(r.Values.ToArray())) 'สร้างแถว (200,000 Rows)
GridView1.DataSource = dtTemp
GridView1.DataBind()
End If
Public Shared Function ExpandoObjectToJson(ByVal expandoObj As ExpandoObject) As String
Dim sz As New JavaScriptSerializer() ' Json.NET (www.codeplex.com/json.NET)
Dim json As New StringBuilder()
Dim lstkv As New List(Of String)()
Dim tmpDog As IDictionary(Of String, Object) = TryCast(expandoObj, IDictionary(Of String, Object))
json.Append("{")
For Each kv As KeyValuePair(Of String, Object) In tmpDog
lstkv.Add(If(TypeOf kv.Value Is ExpandoObject, String.Format("""{0}"": {1}", kv.Key, TryCast(kv.Value, ExpandoObject).ToList()), String.Format("""{0}"": {1}", kv.Key, sz.Serialize(kv.Value))))
Next
json.Append(String.Join(",", lstkv.ToArray()))
json.Append("}")
Return json.ToString()
End Function
Project Description ColorCode is a library for colorizing source code (also known as syntax highlighting).
Language Support
ColorCode supports the following languages:
XML
Java
JavaScript
SQL
C#
VB.NET
ASPX (C#)
ASPX (VB.NET)
C++
PHP
PowerShell
Typescript
FSharp
Dim list = lstEpdObj.Cast(Of IDictionary(Of String, Object))().ToList()
Dim c0 = list.FindAll(Function(key) key.Item("dynRow0") = "Value-00")
Dim c1 = list.FindAll(Function(key) key.Item("dynRow0").ToString().EndsWith("0"))
Dim c2 = list.FindAll(Function(key) key.Values()(0).ToString().EndsWith("0"))
Dim c3 = list.FindAll(Function(key) key.Values()(1).ToString().StartsWith("V"))
Dim c4 = list.FindAll(Function(key) key.Values()(2).ToString().EndsWith("2"))
Dim c5 = list.FindAll(Function(key) key.Values()(3).ToString().Contains("00"))