public actionresult edit(intid)
equals
new
select
new classinformation ;
classinformation k =result.single();
viewdata["k
"] =k;
return
view();
}}
借助於匿名型別:其實和解決按多條件分組的思路是一樣的。
var a = from m in dbcontext.set()join q
in dbcontext.set()
on
new equals new
where m.phone1 !=null
select
new;
a = a.orderby(m => m.phone1).skip(2).take(2);
select[extent1].[id] as [id],
[extent1].[phone1] as [phone1],
as [c1]
from [dbo].[t1] as [extent1]
inner join [dbo].[t2] as [extent2] on ([extent1].[id] = [extent2].[id]) and (([extent1].[phone1] = [extent2].[phone2]) or (([extent1].[phone1] is null) and ([extent2].[phone2] is null)))
where [extent1].[phone1] is not null
所以linq為什麼要這麼寫,看到生成的sql語句 就不言而喻了,因為linq多管閒事的將null給總結進去了
Linq中的連線 join
linq中連線主要有組連線 內連線 左外連線 交叉連線四種。各個用法如下。1 組連線 組連線是與分組查詢是一樣的。即根據分組得到結果。如下例,根據publisther分組得到結果。使用組連線的查詢語句如下 使用組連線 var groupquery from publisher in sampleda...
Linq中的連線 join
linq中連線主要有組連線 內連線 左外連線 交叉連線四種。各個用法如下。1 組連線 組連線是與分組查詢是一樣的。即根據分組得到結果。如下例,根據publisther分組得到結果。使用組連線的查詢語句如下 使用組連線 var groupquery from publisher in sampleda...
Linq 中查詢乙個表中指定的字段
linq中查詢乙個表中指定的幾個字段 var ts t.findallitems where p p.companyid cursiteuser.companyid select s new distinct tolist orderbydescending s s.billperiod take ...