linq
[Column(Name = "ContactName")]
public string Name { get; set; }
[Column] public string City {get; set;}
}
以 Northwind 数据库为例,上述 Customers 类被映射成一个表,对应数据库中的 Customers 表。然后在类型中定义了三个属性,对应表中的三个字段。其中,CustomerID 字 段是主键,如果没有指定 Column 特性的 Name 属性,那么系统会把属性名作为数据表的字 段名,也就是说实体类的属性名就需要和数据表中的字段名一致。 现在,创建一个 ASP.NET 页面,然后在页面上加入一个 GridView 控件,使用下面的代 码进行绑定数据: using System.Data.Linq;
DataContext ctx = new DataContext("server=xxx;database=Northwind;uid=xxx;pwd=xxx");
Table<Customer> Customers = ctx.GetTable<Customer>(); GridView1.DataSource = from c in Customers where c.CustomerID.StartsWith("A") select new {顾客 ID=c.CustomerID, 顾客名=c.Name, 城市=c.City}; GridView1.DataBind();
使用 DataContext 类型把实体类和数据库中的数据进行关联。 你可以直接在 DataContext 的构造方法中定义连接字符串,也可以使用 IDbConnection: using System.Data.SqlClient;
IDbConnection conn = new



.NET 3.5系列培训(二)——LINQ 2 SQL_IT/计算机_专业资料。.NET 3.5系列培训(二)——LINQ 2 SQL,PPT.NET 3.5系列培训(二)——LINQ 2 SQL 朱晔 2010年10...
SharePoint 2010 开发文档-LINQ2SharePoint_IT/计算机_专业资料。详细的介绍了sharepoint 2010 的核心功能及模块。Motivation for LINQ LINQ Syntax LINQ to SharePoint...
LINQ资料_计算机软件及应用_IT/计算机_专业资料。Linq2 objectw 页码,1/1(W) 全部折叠 代码:C# .NET Framework 开发人员指南 LINQ to ADO.NET 请参见 发送反馈...
Where - Simple 2 public void Linq2() { List products = GetProductList(); var soldOutProducts = from p in products where p.UnitsInStock == 0 select ...
public void Linq2() { //定义数据源 List<Product> products = GetProductList(); //定义查询子句 var expensiveInStockProducts = from p in products where ...
101 个 LINQ 例子 1 2008 年 11 月 27 日 星期四 下午 05:21 Restriction...Where - Simple 2 public void Linq2() { List products = GetProductList()...
(x); } } Where - Simple 2 public void Linq2() { List products = GetProductList(); var soldOutProducts = from p in products where p.UnitsInStock =...
Where - Simple 2 public void Linq2() { List products = GetProductList(); var soldOutProducts = from p in products where p.UnitsInStock == 0 select ...
“在 Linq To Sql 正式推出之前,很多人只是把 sql 语句形成一个 string,然后...{"1","2","3"})); 很多时候我们需要对 CLR 类型进行一些操作,苦于无法...
闽公网安备 35021102001881号 
热门文档