[问题] 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