Connecting Tech Pros Worldwide Help | Site Map

convert a SQL script to asp.net

Newbie
 
Join Date: Jan 2009
Posts: 1
#1: Jan 26 '09
I have the following SQL script that I'd like to convert into ASP.Net (LINQ) code. I figure out part of the solution but I need help with the rest.

SQL Script:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT TOP 10 Orders.OrderID, Orders.OrderDate, [Order Subtotals].Subtotal AS SaleAmount, Customers.CompanyName AS CompanyName, Orders.ShippedDate
  2.  
  3. FROM Customers INNER JOIN (Orders INNER JOIN [Order Subtotals] ON Orders.OrderID = [Order Subtotals].OrderID) ON Customers.CustomerID = Orders.CustomerID
  4.  
  5. ORDER BY [Order Subtotals].Subtotal DESC;
  6.  
Here's what I have so far:
Expand|Select|Wrap|Line Numbers
  1.         var expr = ((from o in db.Orders
  2.                      join c in db.Customers on o.CustomerID equals c.CustomerID
  3.                      select new { o.OrderID, o.OrderDate, SalesAmount = o.OrderID, c.CompanyName, o.ShippedDate }).Take(10)).Distinct();
  4.  
Thx in advance.
Reply