The following syntax converts a DataTable to a Dictionary .

 

in C#

Dictionary<string, string> dicCodes = ds.Tables[0].AsEnumerable()
                                    .ToDictionary<DataRow, string, string>(
                                        row => row.Field<string>("Column1Name"),
                                        row => row.Field<string>("Column2Name")
                                    );

 

in VB.NET

Dim dicCodes As Dictionary(Of String, String) =
    ds.Tables(0).AsEnumerable() _
    .ToDictionary(Of String, String)(
                                        Function(row) row.Field(Of String)("Column1Name"),
                                        Function(row) row.Field(Of String)("Column2Name")
                                    )

 

be the happy Gosu.

woojja ))*

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

반응형

Hands On Lab 입니다.

Visual Basic LINQ Hands On Labs for Orcas Beta 1


행복한 고수되세요...


woojja ))*
\\\\\\\\\\\\\\\\\\\\\\\\\\\
반응형

+ Recent posts