嘿伙计们,我想在实体框架中执行这个 SQL 脚本并以JSONResult
格式返回结果以在 jQuery 中访问。请帮助!!!
我的实体框架模型包含 SQL 脚本中提到的表和数据库
谢谢 :-)
DECLARE @listCol VARCHAR(2000)
DECLARE @query VARCHAR(4000)
SELECT @listCol = STUFF(( SELECT distinct '], [' + [PSize]
FROM Pattern
FOR
XML PATH('')
), 1, 2, '') + ']'
SET @query = 'SELECT * FROM
(SELECT PColour as Colour_Size_Matrix, PSize, PCode
FROM Pattern
) src
PIVOT (Count(PCode) FOR PSize
IN (' + @listCol + ')) AS pvt'
EXECUTE ( @query )