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

📄 frmsingletable.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 FrmSingleTable : Form
	{
		private NorthwindDataSet northwindDataSet;

		public FrmSingleTable()
		{
			InitializeComponent();
		}

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

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

			var selectedRows = from row in northwindDataSet.Products
							   where row.Category_ID == 1
							   orderby row.Product_ID descending
							   select row;

			/*DataSet dataSet = northwindDataSet;
			var selectedRows2 = from row in dataSet.Tables["Products"].AsEnumerable()
							   where row.Field<int>("Category ID") == 1
							   orderby row.Field<int>("Product ID") descending
							   select row;*/

			dataGrid1.DataSource = selectedRows.AsDataView();

			Cursor.Current = Cursors.Default;
		}
	}
}

⌨️ 快捷键说明

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