How we select data from SDF (webmatrix) database in visual studio with Linq just like we can with northwind, like this:?
// 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);
}
Ref: http://msdn.microsoft.com/en-us/library/bb399398.aspx
please thank you for your help.
I don’t believe that Linq To SQL is officially supported with SQL Server CE 4.0, although it appears you can get it working. Microsoft’s recommended approach is to use the Entity Framework.
I’ve written a couple of articles on using EF with SQL Server CE in WebMatrix. One covers the Code First approach, and the other looks at a database first approach.