Querying a Data Table Using Select Method and Lambda Expressions in Dot Net
.Net Questions and Ans.. Q. 1 Querying a Data Table Using Select Method and Lambda Expressions in Dot Net Suppose we have a DataTable object having four fields: SSN, NAME, ADDRESS and AGE. We could create a data table and add columns in the following way: DataTable dt = new DataTable (); dt.Columns.Add( "SSN" , typeof ( string )); dt.Columns.Add( "NAME" , typeof ( string )); dt.Columns.Add( "ADDR" , typeof ( string )); dt.Columns.Add( "AGE" , typeof ( int )); // Showing how to set Primary Key(s) in a Data table (Although it's not compulsory to have one) DataColumn [] keys = new DataColumn [1]; keys[0] = dt.Columns[0]; dt.PrimaryKey = keys; Now we store some data in our data table "dt" to show how we can perform several queries on the DataTable object like filtering some data, finding a person's record...