我看过不少类似的例子,但是在这个例子中复制它们似乎行不通。有没有人知道以下代码有什么问题...
var products = new[]
{
new {ProductName ="Soda", Category = "Beverages"},
new {ProductName ="Tuna", Category = "SeaFood"},
new {ProductName ="Jam", Category = "Condiment"}
};
var categories = new[]
{
new {Category = "Beverages", Description="Slurp"},
new {Category = "SeaFood" , Description="Nosh"},
new {Category = "Exotic" , Description="Spicy!"},
};
var q = from c in categories
join p in products on c.Category equals p.Category into tmp
from prd in tmp.DefaultIfEmpty()
select new { Category = c.Category,
Description = c.Description,
ProductName = prd.ProductName };
非常感谢您的提前帮助。 Keith