https://msdn.microsoft.com/zh-cn/library/bb386916.aspx
int iEmailCount1 = ds.Tables[0].AsEnumerable().Where(x => x.Field<string>("Email") != "").GroupBy(x => x.Field<string>("Email")).Count();
// Fill the DataSet. DataSet ds = new DataSet(); ds.Locale = CultureInfo.InvariantCulture; FillDataSet(ds); DataTable products = ds.Tables["Product"]; var query = from product in products.AsEnumerable() where product.Field<string>("Color") == "Red" select new { Name = product.Field<string>("Name"), ProductNumber = product.Field<string>("ProductNumber"), ListPrice = product.Field<Decimal>("ListPrice") }; foreach (var product in query) { Console.WriteLine("Name: {0}", product.Name); Console.WriteLine("Product number: {0}", product.ProductNumber); Console.WriteLine("List price: ${0}", product.ListPrice); Console.WriteLine(""); }
/*********************************************************************************/
DataSet ds = new DataSet(); ds.Locale = CultureInfo.InvariantCulture; FillDataSet(ds); DataTable products = ds.Tables["Product"]; var query = from product in products.AsEnumerable() where !product.IsNull("Color") && (string)product["Color"] == "Red" select new { Name = product["Name"], ProductNumber = product["ProductNumber"], ListPrice = product["ListPrice"] }; foreach (var product in query) { Console.WriteLine("Name: {0}", product.Name); Console.WriteLine("Product number: {0}", product.ProductNumber); Console.WriteLine("List price: ${0}", product.ListPrice); Console.WriteLine(""); }