translate stored procedure - to Linq2SQL (count, max, group, orderby)
Posted
by Walter
on Stack Overflow
See other posts from Stack Overflow
or by Walter
Published on 2009-08-12T21:00:01Z
Indexed on
2010/05/08
7:08 UTC
Read the original article
Hit count: 315
I've two tables (1:N)
CREATE TABLE master (idMaster int identity (1,1) not null,
TheName varchar( 100) null,
constraint pk_master primary key(idMaster) clustered)
and -
CREATE TABLE lnk (idSlave int not null,
idMaster int not null,
constraint pk_lnk_master_slave(idSlave) primary key clustered)
link between Master.idMaster and lnk.idMaster
I've a SQL query:
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
I need to translate this T-SQL query to a Linq-to-SQL statement, preferably in C#
© Stack Overflow or respective owner