嗨,我需要找到一种方法来为方法声明匿名类型。这是我的代码:
public List<var> ListOfProducts(string subcategory)
{
var products = (from p in dataContext.Products
join s in dataContext.SubCategories.Where(x => x.SubCatName == subcategory)
on p.SubcatId equals s.SubCatId
join b in dataContext.Brands on p.BrandId equals b.BrandId
select new
{
Subcategory = s.SubCatName,
Brand = b.BrandName,
p.ProductName,
p.ProductPrice
});
return products;
}
我不知道我应该为方法设置什么类型的列表。在这种情况下我该怎么办?