Linq - Cross join sample

Saratvaddilli
Posted by Saratvaddilli under LINQ category on | Points: 40 | Views : 1449
public void Linqsample()
{
string[] categories = new string[]{
"Beverages",
"Condiments",
"Vegetables",
"Dairy Products",
"Seafood" };

List<Product> products = GetProductList();



var q =
from c in categories
join p in products on c equals p.Category into ps
from p in ps
select new { Category = c, p.ProductName };

foreach (var v in q)
{
Console.WriteLine(v.ProductName + ": " + v.Category);
}
}

Comments or Responses

Login to post response