Download Visual Studio 2008 and Sql Server 2005 for Linq Samples
If you newbie to linq, you should download and install some tools for trying samples and developing apps.
Visual Studio 2008 and Sql Server express editions:
If you newbie to linq, you should download and install some tools for trying samples and developing apps.
Visual Studio 2008 and Sql Server express editions:
T-Sql coalesce usage:
select c.ContactName, EmpID= coalesce(o.EmployeeID,-1)
from Customers c
left outer join Orders o on o.CustomerID = c.CustomerID
Same Query with Linq ?? operator:
T-Sql exists Usage:
select c.CompanyName, o.*
from Customers c
join Orders o on o.CustomerId = c.CustomerId
where o.ShipCountry = ‘Germany’
Linq contains usage instead of exists:
DataClassesDataContext db = new DataClassesDataContext();
var Cust = from c in db.Customers
join o in db.Orders on c.CustomerID equals o.CustomerID
where o.ShipCountry == “Germany”
select new { c.CompanyName, o.OrderDate, o.ShipCountry };
T-Sql exists Usage:
select *
from Customers c
where exists(select *
from Orders
where ShipCountry = ‘Germany’
and CustomerId = c.CustomerId)
Linq contains usage instead of exists:
DataClassesDataContext db = new DataClassesDataContext();
var Cust = from c in db.Customers
where (from o in db.Orders
where o.ShipCountry == “Germany”
select o.CustomerID).Contains(c.CustomerID)
select c;
Powered by Mucitsoft
Recent Comments