How to Use the DataContext
Northwind db = new Northwind(@"Data Source=.\SQLEXPRESS;Initial
Catalog=Northwind");
db.Log = Console.Out;
IQueryable<Order> orders = from c in db.Customers
from o in c.Orders
where c.Country == "USA" && c.Region == "WA"
select o;
foreach(Order item in orders)
Console.WriteLine("{0} - {1} - {2}", item.OrderDate, item.OrderID,
item.ShipName);
OUTPUT:
SELECT [t1].[OrderID], [t1].[CustomerID], [t1].[EmployeeID], [t1].[OrderDate],
[t1].[RequiredDate], [t1].[ShippedDate], [t1].[ShipVia], [t1].[Freight],
[t1].[ShipName], [t1].[ShipAddress], [t1].[ShipCity], [t1].[ShipRegion],
[t1].[ShipPostalCode], [t1].[ShipCountry]
FROM [dbo].[Customers] AS [t0], [dbo].[Orders] AS [t1]
WHERE ([t0].[Country] = @p0) AND ([t0].[Region] = @p1) AND ([t1].[CustomerID] =
[t0].[CustomerID])
-- @p0: Input String (Size = 3; Prec = 0; Scale = 0) [USA]
No comments:
Post a Comment