摘要:LinQ
陣列中查詢
int[] iArray = new int[] { 55, 33, 54, 27, 95 };
//接收的變數型態為Var
//關鍵字大小寫有差
var Cmd = from data in iArray
where data > 20
select data;
foreach (var result in Cmd)
{
Response.Write(result +"\n");
}
Linq to sql
OcacDataContext DB = new OcacDataContext();
//↑去dbml裡面看
var Result = from p in DB.Users
//↑資料表名稱
select p;
foreach(var item in Result)
{
Response.Write(item.UserName + "\n");
//↑欄位名稱
Response.Write(item.UserName + "\n");
}