dataGridView1.DataSource = q;
vi)
DataClasses1DataContext dc = new DataClasses1DataContext();
var q= (from orders in dc.GetTable<Order>()
from orderDetails in dc.GetTable<Order_Detail>()
from prods in dc.GetTable<Product>()
where ((orderDetails.OrderID == orders.OrderID) &&
(prods.ProductID == orderDetails.ProductID) &&
(orders.EmployeeID == 1))
orderby orders.ShipCountry
select new CustomerOrderResult
{
CustomerID = orders.CustomerID,
CustomerContactName = orders.Customer.ContactName,
CustomerCountry = orders.Customer.Country,
OrderDate = orders.OrderDate,
EmployeeID = orders.Employee.EmployeeID,
EmployeeFirstName = orders.Employee.FirstName,
EmployeeLastName = orders.Employee.LastName,
ProductName = prods.ProductName
}).ToList<CustomerOrderResult>();
dataGridView1.DataSource = q;
vii)
DataClasses1DataContext dc = new DataClasses1DataContext();
var query = (from orders in dc.GetTable<Order>()
from orderDetails in dc.GetTable<Order_Detail>()
from prods in dc.GetTable<Product>()
where ((orderDetails.OrderID == orders.OrderID)
&& (prods.ProductID == orderDetails.ProductID)
&& (orders.EmployeeID == 1))
orderby orders.ShipCountry
select new CustomerOrderResult
{
CustomerID = orders.CustomerID,
CustomerContactName = orders.Customer.ContactName,
CustomerCountry = orders.Customer.Country,
OrderDate = orders.OrderDate,
EmployeeID = orders.Employee.EmployeeID,
EmployeeFirstName = orders.Employee.FirstName,
EmployeeLastName = orders.Employee.LastName,
ProductName = prods.ProductName
}).ToList<CustomerOrderResult>();
var matches = (from c in query
where c.CustomerID == "RICAR"
select c).ToList<CustomerOrderResult>();
dataGridView1.DataSource = matches;
viii)
DataClasses1DataContext dc = new DataClasses1DataContext();
var query = (from orders in dc.GetTable<Order>()
select orders);
var matches = (from c in query
where c.OrderID == 10248
select
c.Employee.LastName).SingleOrDefault<System.String>();
MessageBox.Show(matches);