📄 frmsingletable.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 + -