4
我有一個像使用LINQ選擇列表
{
"Nutrients": [{
"vitamin": "vitamin C",
"potassium": "195mg",
"sodium": "2mg",
"cholesterol": "",
"display_name": "Apple"
}, {
"vitamin": "vitamin B",
"potassium": "176mg",
"sodium": "2mg",
"cholesterol": "",
"display_name": "Grape"
}],
"General_name": "Fruits",
"country_of_origin": "France"
}
{
"Nutrients": [{
"vitamin": "vitamin B",
"potassium": "196mg",
"sodium": "115mg",
"cholesterol": "123mg",
"display_name": "Chicken"
}, {
"vitamin": "vitamin B",
"potassium": "360mg",
"sodium": "53mg",
"cholesterol": "68mg",
"display_name": "Chicken"
}],
"General_name": "Meat",
"country_of_origin": "Denmark"
}
名單,我需要找到具有膽固醇空字符串值項的General_name以外的項目。
我試圖使用LINQ lambda表達式作爲
var elements=items.SelectMany(c =>c.Nutrients)
.Where(a => !string.IsNullOrEmpty(a.cholesterol))
.ToList();
我的問題是如何從這種情況
是的,我忘了布爾選項。感謝 – Mithun
@Mithun - 很高興爲你工作。請考慮接受答案(請參閱[如何接受所有答案](http://meta.stackexchange.com/a/5235)),一旦過了15分鐘。 – Igor
有沒有辦法讓我可以得到這些物品的display_name? – Mithun