LINQ Query vs Lambda Expression
- by FosterZ
What is the difference between the following two snippets (i.e LINQ Query vs Lambda Expression)
LINQ Query
public Product GetProduct(int productID)
{
AdventureWorksDBDataContext db = new AdventureWorksDBDataContext();
Product product = (from p in db.Products
where p.ProductID == productID
select p).Single();
return product;
}
Using a Lambda expression
public Product GetProduct(int productID)
{
AdventureWorksDBDataContext db = new AdventureWorksDBDataContext();
Product product = db.Products.Single(p = p.ProductID == productID);
return product;
}