我有两张桌子 (1:N)
CREATE TABLE master (idMaster int identity (1,1) not null,
TheName varchar( 100) null,
constraint pk_master primary key(idMaster) clustered)
和 -
CREATE TABLE lnk (idSlave int not null,
idMaster int not null,
constraint pk_lnk_master_slave(idSlave) primary key clustered)
Master.idMaster 和 lnk.idMaster 之间的链接
我有一个 SQL 查询:
select max (master.idMaster) as idMaster,
master.theName,
count (lnk.idSlave) as freq
from lnk
inner join master ON lnk.idMaster = master.idMaster
Group by master.theName
order by freq desc, master.theName
我需要将此 T-SQL 查询转换为 Linq-to-SQL 语句,最好在 C# 中