我的問題是關於從這個MSDN文章代碼示例:
Getting Started (LINQ to SQL)非常基本的LINQ到SQL問題
下面的代碼在文章中列出:
// Northwnd inherits from System.Data.Linq.DataContext.
Northwnd nw = new Northwnd(@"northwnd.mdf");
var companyNameQuery =
from cust in nw.Customers
where cust.City == "London"
select cust.CompanyName;
foreach (var customer in companyNameQuery)
{
Console.WriteLine(customer);
}
如何「NW」創建?數據類型「Northwnd」來自哪裏?我該如何以這種方式訪問我的數據庫?我正在編寫一個訪問SQL服務器的應用程序,並且使用服務器資源管理器將相應的DBML文件添加到了我的項目中。但我不知道如何編寫這行代碼來訪問我的數據庫。
完美答案!非常感謝!這正是我需要知道的。 – Giffyguy 2009-07-01 23:49:51