C# 在LINQ to DataSet中对分组操作执行子查询
代码说明:
C# 在LINQ to DataSet中对分组操作执行子查询,相关代码: private void button1_Click(object sender, EventArgs e) {//在LINQ to DataSet中对分组操作执行子查询 SqlConnection MyConnection = new SqlConnection(); MyConnection.ConnectionString = @"Data Source =.SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"; MyConnection.Open(); SqlCommand MyCommand = new SqlCommand("Select * From Orders ", MyConnection); DataSet MySet = new DataSet(); SqlDataAdapter MyAdapter = new SqlDataAdapter(MyCommand); MyAdapter.Fill(MySet); DataTable MyQueryTable = MySet.Tables[0]; var MyQuery = from MyOrder in MyQueryTable.AsEnumerable() orderby MyOrder.Field("ShipCity") group MyOrder by MyOrder.Field("ShipCity") into g select new { MyCity = g.Key, MyMaxFreight = (from MyData in g select MyData.Field("Freight")).Max()
下载说明:请别用迅雷下载,失败请重下,重下不扣分!


