您的位置:首页 > 其它

wpf dataGrid 简单数据绑定

2011-05-16 20:53 429 查看
数据实体类:
[Table(Name = "customers")]
public class Customer
{

private string _CustomerID;
[Column(IsPrimaryKey=true,Storage="_CustomerID")]
public string CustomerID
{
get
{
return this._CustomerID;www.wpf123.com
}
set
{
this._CustomerID = value;
}
}

private string _City;
[Column(Storage = "_City")]
public string City
{
get
{
return this._City;
}
set
{
this._City = value;
}
}

private string _CompanyName;
[Column(Storage = "_CompanyName")]
public string CompanyName
{
get
{
return this._CompanyName;
}
set
{
this._CompanyName = value;
}
}

dataGrid数据绑定:

System.Data.Linq.DataContext db = new DataContext("Data Source=.;Initial Catalog=northwind;Integrated Security=True");
Table<Customer> customers = db.GetTable<Customer>();

IQueryable<Customer> custQuery =
from cust in customers
where cust.City == "London"
select cust;
dataGrid1.ItemsSource = custQuery.ToList();



http://www.wpf123.com/news/?185.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: