数据实体类:
[Table(Name = "customers")]
[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数据绑定:
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();
作者:wpf之家
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。