我们如何使用 Linq 从 Visual Studio 中的 SDF (webmatrix) 数据库中选择数据,就像我们使用北风一样,像这样:?
// Northwnd inherits from System.Data.Linq.DataContext.
Northwnd nw = new Northwnd(@"northwnd.mdf");
// or, if you are not using SQL Server Express
// Northwnd nw = new Northwnd("Database=Northwind;Server=server_name;Integrated Security=SSPI");
var companyNameQuery =
from cust in nw.Customers
where cust.City == "London"
select cust.CompanyName;
foreach (var customer in companyNameQuery)
{
Console.WriteLine(customer);
}
参考:http: //msdn.microsoft.com/en-us/library/bb399398.aspx
请感谢您的帮助。