拥有这两个类和这个 linq 请求:
var cats = from c in xml.Descendants("category")
let categoryName = c.Attribute("name").Value
let descendants = c.Descendants()
select new Category
{
Name = categoryName,
Items = from d in descendants
let typeId = d.Attribute("id").Value
select new Item
{
Id = typeId,
Name = d.Value,
Category = ???????
}
};
class Category
{
string Name;
IEnumerable<Item> Items;
}
class Item
{
string Id;
string Name;
Category Category;
}
如何将项目的类别影响到当前选定的类别?一种this
可能的关键字?