LINQ Query vs Lambda Expression
Posted
by FosterZ
on Stack Overflow
See other posts from Stack Overflow
or by FosterZ
Published on 2010-03-17T09:10:40Z
Indexed on
2010/03/17
9:31 UTC
Read the original article
Hit count: 308
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;
}
© Stack Overflow or respective owner