LINQ over untyped DataSets

This example comes from the AppDev (Exploring Visual Studio 2008 Using Visual C#)

DataSetr ds = FillDataset();
DataTable customerTable = ds.Tables["Customers"];

// DataTable does not implement IEnumerable
var cutomers = from c in customerTable.AsEnumerable()
where c.Field("Country") == "USA"
select new
CustomerID = c.Field("CustomerID"),
ContractName = c.Field("ContractName")

Author: Pouya Panahy

Microsoft certified DevOps engineer with passion in analysing, designing and implementing solutions for Azure Cloud with hands-on experience in security and quality assurence.

Leave a Reply