SELECT [D_Contract.ContractNo AS D_Contract_ContractNo], [D_Contract.ContractType], D_Contract.CONTRACT, D_Contract.Title AS D_Contract_Title, [D_ContractType.ContractType], D_ContractType.ICODE, D_ContractType.Title AS D_ContractType_Title, [D_Calendar.Yieldpoint AS D_Calendar_Yieldpoint], D_Calendar.deliveryMonth, D_Calendar.Mnemonic, D_Calendar.monthCode, D_Calendar.Expires, [D_Curve.ContractNo AS D_Curve_ContractNo], [D_Curve.Yieldpoint AS D_Curve_Yieldpoint] FROM (D_Contract INNER JOIN D_ContractType ON D_Contract.ContractType = D_ContractType.ContractType) INNER JOIN (D_Calendar INNER JOIN D_Curve ON D_Calendar.Yieldpoint = D_Curve.Yieldpoint) ON D_Contract.ContractNo = D_Curve.ContractNo; +++++++++++++++++++++++++++++++++++++++++++ CREATE TABLE [dbo].[D_Calendar]( [Yieldpoint] [int] IDENTITY(1,1) NOT NULL, [deliveryMonth] [int] NULL, [Mnemonic] [varchar](10) NULL, [monthCode] [varchar](2) NULL, [Expires] [datetime] NULL, [MarketNo] [int] NULL, CREATE TABLE [dbo].[D_Curve]( [SeriesNo] [int] IDENTITY(1,1) NOT NULL, [ContractNo] [int] NOT NULL, [Yieldpoint] [int] NOT NULL, CREATE TABLE [dbo].[D_Contract]( [ContractNo] [int] IDENTITY(1,1) NOT NULL, [ContractType] [int] NULL, [CONTRACT] [varchar](14) NULL, [Title] [varchar](36) NULL, [MarketNo] [int] NULL, [LegCount] [int] NULL, [PVTickValue] [int] NULL, [PMTickSize] [numeric](15, 2) NULL, [AE] [varchar](1) NULL, [INV] [int] NULL, [FEES] [varchar](1) NULL, [LAG] [int] NULL, [DELIVERS] [varchar](10) NULL, [MODEL] [int] NULL, CREATE TABLE [dbo].[D_MarketData]( [SeriesNo] [int] NOT NULL, [LotsTraded] [int] NULL, [PriceLastTrade] [int] NULL, [LotsLastTrade] [int] NULL, [PriceHigh] [int] NULL, [PriceLow] [int] NULL, [PriceSecondLastTrade] [int] NULL, [PriceThirdLastTrade] [int] NULL, [PriceOpen] [int] NULL, [PriceSettle] [int] NULL, [OpenInterest] [int] NULL, [TimeLastTrade] [datetime] NULL, CREATE TABLE [dbo].[D_MarketType]( [MarketNo] [int] NOT NULL, [MarketCode] [varchar](10) NULL, [Title] [varchar](32) NULL, [isTrading] [varchar](1) NULL, [MarketID] [varchar](1) NULL, [C_trading_right_block_size] [tinyint] NULL, CREATE TABLE [dbo].[D_ContractType]( [IDN] [int] NOT NULL, [Title] [varchar](56) NULL, [ICODE] [varchar](50) NULL, [SAMPLE] [varchar](14) NULL, Select D_Contract.ContractNo, D_Calendar.deliveryMonth, D_Calendar.Mnemonic, D_Calendar.monthCode, D_Calendar.Expires From D_Contract, D_Calendar, D_Curve Where D_Contract.ContractNo = D_Curve.ContractNo and D_Calendar.Yieldpoint = D_Curve.Yieldpoint //var qry = db.D_Calendar.Select( D_Contract.ContractNo == D_Curve.ContractNo and D_Calendar.Yieldpoint = D_Curve.Yieldpoint p => new { p.GroupingID, p.Name } ).OrderBy(p => p.Name); var q = from m in db.D_Calendar from y in db.D_Curve from c in db.D_Contract where c.ContractNo == y.ContractNo and m.Yieldpoint == y.Yieldpoint select new {c.ContractNo,m.deliveryMonth,m.Mnemonic, m.monthCode,m.Expires}; var query = from m in db.D_Calendar join y in db.D_Curve on m.Yieldpoint equals y.Yieldpoint join c in db.D_Contract on y.ContractNo equals c.ContractNo /* select new {m, c}; */ select new {c.ContractNo,m.deliveryMonth,m.Mnemonic, m.monthCode,m.Expires}; .Where( c ==> ) using (var db = new DataClasses1DataContext()) { var query = from ot in db.OTs join v in db.Vehicles on ot.vehicle_id equals v.id join c in db.Clients on v.client_id equals c.id where c.Name == clientName select new {ot, c}; foreach (var q in query) { Console.WriteLine("OT ID = {0} Customer Name = {1}", q.ot.id, q.c.Name ); } } var q = from m in db.D_Calendar from y in db.D_Curve from c in db.D_Contract where c.ContractNo == y.ContractNo and m.Yieldpoint == y.Yieldpoint select new {c.ContractNo,m.deliveryMonth,m.Mnemonic, m.monthCode,m.Expires}; FROM D_Contract join m in db.D_Calendar on ( D_Calendar INNER JOIN D_Curve ON D_Calendar.Yieldpoint = D_Curve.Yieldpoint ) ON D_Contract.ContractNo = D_Curve.ContractNo; // use query expressions to simplify common select/where patterns var q = from c in db.Customers from o in c.Orders where c.City == "London" select new {c.ContactName, o.OrderDate}; // use group x by y to produce a series of group partitions var q = from p in db.Products group p by p.CategoryID into Group select new {CategoryID=Group.Key, Group}; // use group-by and aggregates like Min()/Max() to compute values over group partitions var q = from p in db.Products group p by p.CategoryID into g select new { Category = g.Key, MinPrice = g.Min(p => p.UnitPrice), MaxPrice = g.Max(p => p.UnitPrice) }; // Combine Where() and Select() for common queries var q = db.Customers.Where(c => c.City == "London").Select(c => c.ContactName); IEnumerable q = db.Customers.Where(c => c.City == "London"); // use First() in place of Where() to find the first or only one Customer cust = db.Customers.First(c => c.CustomerID == "ALFKI"); // Use Select() to map/project results var q = db.Customers.Select(c => c.ContactName); // use Anonymous Type constructors to retrieve only particular data var q = db.Customers.Select(c => new {c.ContactName, c.Phone}); // use SelectMany() to flatten collections IEnumerable q = db.Customers.SelectMany(c => c.Orders); // use orderby to order results var q = from c in db.Customers orderby c.City, c.ContactName select c; // use Any() to determine if a collection has at least one element, or at least one element matches a condition var q = from c in db.Customers where c.Orders.Any() select c; // use All() to determine if all elements of a collection match a condition (or that the collection is empty!) var q = from c in db.Customers where c.Orders.All(o => o.ShipCity == c.City) select c;