I am just starting learning about Linq. I wrote some examples but there is a doubt that I haven’t been able to solve.
I am working with the Northwind database, I just used the tool called SqlMetal in order to make all the modeling.
Right now I just wrote the following query:
var q = from c in db.Customers
from o in c.Orders
where c.City == "London"
select new { c, o };
I know that this query brings to me a resulting set of data that contains all the columns of the Customers and Orders tables for the given condition (c.City == "London"). But my question is:
After executing that query, How can I get the value of the column Customers.CustomerID and Orders.OrderID FROM THE VARIABLE q?
Maybe this is a silly question but I have been struggling with this for a couple hours, thanks in advance.
Also, if that was the only columns you cared about, your initial query would be faster with:
You could also change the names as you go:
The latter being the only option if rather than directly referencing a property, you reference a method call.