型別 查詢變數 = from 臨時變數in 集合物件或資料庫物件
[where 條件表示式]
[order by 條件]
select 臨時變數中被查詢的值
[group by 條件]
簡單的查詢
var movies = from c in db.movies
select c; //此處是乙個集合
sql : select * from db.movies
2. 帶where 條件的查詢
movies = movies.where(w =>w.id>10);
sql :select * from movies where id>10
3. 排序order by desc/asc
var ss = from r in db.movies where r.id > 10
orderby r.id descending //倒序
//orderby r.id ascending //正序
select r;
//正序
var ss1 = db.movies .orderby(p => p.id).where(p => p.id> 10).tolist();
//倒序
var ss2 = db.movies .orderbydescending(p => p.id).where(p => p.id> 10).tolist();
sql : select * from movies where id>10 order by id desc; // or asc
4.top
//如果取最後乙個可以按倒敘排列再取值
var ss = (from r in db.movies
select r).firstordefault();
var ss1 = db.movies .firstordefault();
//var ss1 = db.movies .first();
sql = select top(1) * from movies ;
5.包含,類似 like
var ss = from r in db.movies
where r.sortstext.contains("張")
select r;
var aa= db.movies .where(p => p.title.contains("張")).tolist();
sql = select * from movies where title like '%張%';
6.連線查詢
var bb= from r in db.movies
join w in db.movies2 on r.vid equals w.mid
orderby r.vid descending
select r;
var aa = db.movies .join(db.movies2 , p => p.vid , r => r.vid , (p, r) => p).orderbydescending(p => p.vid ).tolist();
sql = select r.* from movies as r inner join dbo.movies2 as t on r.vid = t.mid order by r.vid desc;
7.sql in
var aa= from p in db.movies
where (new int? ).contains(p.vid )
select p;
foreach (var p in ss)
sql = select * from movies where vid in(24,25,26);
jquery一些基本的語法
基本選擇器 id id選擇器 tagname 標籤選擇器,返回陣列 class 類選擇器,返回陣列 選擇文件中的所有的元素 e.c 選擇樣式名稱為c的e標記 e i 選擇id為i的e標記 層疊選擇器 e,f 選擇所有e元素和所有f元素 並集 e f 選擇e元素內部的所有f元素 子孫節點 e f 選擇...
python的一些基本語法
print kkkjjjsss 6 8 print chr 65 print ord import datetime print datetime.datetime.now import time time.sleep 2.5 a 33,44,444 print len a a 33,44,444 ...
LINQ 的 一些語句
1.找出b1在a1中 以逗號分隔的 完全匹配的字串結果 stringa1 abc,efg,hik,lmn,opq stringb1 efg,d3l,opq,lmn var result a1.split intersect b1.split intersect 通過使用預設的相等比較取出兩個序列的交...