8. SQLの例
SELECT 価格 FROM 商品表 WHERE 価格 < 300 ORDER BY ASC
商品表 価格
価格 <
300
価格 <
300
昇順並び替え
複数の式を結合し、データの塊を最終的な形になるまで操作する。
9. LINQとは
C#でSQLクエリっぽい
書き方ができる
class Product
{
public string name;
public int price;
public Product(string n, int p)
{
name = n;
price = p;
}
}
// Use this for initialization
void Start () {
List<Product> productList = new List<Product>();
productList.Add(new Product("リンゴ", 120));
productList.Add(new Product("みかん", 80));
productList.Add(new Product("お米", 900));
productList.Select(x => x.price)
.Where(x => x < 300)
.OrderBy(x => x);
}