Again, the benefit of LINQ to SQL is that we are able to interact with
relational databases using
a consistent, object-based model. Just to shed some more light on our LINQ query expression, add
the following code statement at the end of your PrintOrderForCustomer() method:
Console.WriteLine("\ncustomerOrders as a string: {0}", customerOrders);
When you run your program once again, you may be surprised to find that the stringified value
of your query expression reveals the underlying SQL query:
SELECT [t0].[FirstName], [t0].[LastName], [t0].[CustID],
[t1].[OrderID], [t1].[CarID], [t1].[CustID] AS [CustID2]
FROM [Customers] AS [t0], [Orders] AS [t1]
WHERE ([t0].[CustID] = @p0) AND ([t1].[CustID] = [t0].[CustID])
Do'stlaringiz bilan baham: