vidhya

vidhya

  • NA
  • 324
  • 88.2k

How can i convert the query into linq

Jul 1 2013 6:39 AM
I placed the query for your reference.
I need to convert into linq.



DECLARE @AssignmentList varchar(3000),@Sql varchar(max)
SET @AssignmentList =STUFF((SELECT DISTINCT ',[' + assignmentname + ']' FROM assignment where coursesectionid='b78a6efe-ac77-4e49-806a-fc2fad71068b' FOR XML PATH('')),1,1,'')

SET @Sql ='select *
from
(
select p.firstname,p.lastname,a.assignmentname,a.pointspossible
from person2 p
inner join coursesectionroster cs
on cs.personid = p.personid
inner join assignment a
on a.coursesectionid = cs.coursesectionid
left join assignmentsubmission asg
on a.assignmentid=asg.assignmentid
where cs.coursesectionid=''b78a6efe-ac77-4e49-806a-fc2fad71068b''
and cs.courserole=2
)t
PIVOT(SUM(pointspossible) FOR assignmentname IN(' + @AssignmentList + '))p'

EXEC (@SQL)




Answers (1)