[問題] LinQ 的一個問題

作者: phi12345 (94life.tw)   2018-10-31 08:18:45
In parts (a)–(c) below suppose there exists a class called Plant that represents the
plants found in a typical garden. Each plant has three public properties: Name (a
string), Planted (the DateTime the plant was placed in the ground) and Poisonous
(a bool, whether or not a person would become sick if the plant was eaten).
a. Assuming the following declaration of a collection of Plants
List garden = new List();
that has been filled with Plant objects, write a LINQ expression that selects
those plants that are poisonous.
我要在這 List garden = new List(); 底下 使用 LinQ 語法
我目前是寫
var query = from garden in Plant
where garden.Name.bool().Contain(name.bool())
select garden;
foreach(garden in Plant)
{
view.Add(garden);
}
這樣是對的嗎?
我目前迷惑的是 from garden in Plant 這一段
from 後面是要寫 資料庫本身的資料表? 還是 List 所定義的name
Plant 是資料表 garden 是 List 所定義的 name
還有 where 那邊我應該要寫
where garden.Name.ToLower().Contain(name.ToLower)))
還是
where garden.Name.bool().Contain(name.bool())

Links booklink

Contact Us: admin [ a t ] ucptt.com