⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmjointables.cs

📁 移动设备的 LINQ 编程介绍 .NET Compact Framework 版 LINQ 的特性
💻 CS
字号:
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Demo3___LinqToDataSet.NorthwindDataSetTableAdapters;

namespace Demo3___LinqToDataSet
{
	public partial class FrmJoinTables : Form
	{
		private NorthwindDataSet northwindDataSet;

		public FrmJoinTables()
		{
			InitializeComponent();
		}

		private void mniLoadData_Click(object sender, EventArgs e)
		{
			Cursor.Current = Cursors.WaitCursor;

			northwindDataSet = new NorthwindDataSet();

			using (CategoriesTableAdapter ta = new CategoriesTableAdapter())
			{
				ta.Fill(northwindDataSet.Categories);
			}

			using (ProductsTableAdapter ta = new ProductsTableAdapter())
			{
				ta.Fill(northwindDataSet.Products);
			}

			var selectedRows = from categoryRow in northwindDataSet.Categories
					   from productRow in northwindDataSet.Products
					   where categoryRow.Category_ID == productRow.Category_ID
					   orderby productRow.Product_ID
					   select new
					   {
						   ProductID = productRow.Product_ID,
						   ProductName = productRow.Product_Name,
						   Category = categoryRow.Category_Name,
						   UnitPrice = productRow.Unit_Price
					   };

			dataGrid1.DataSource = selectedRows.ToList();

			Cursor.Current = Cursors.Default;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -