Hey Guys我想在Entity Framework中执行这个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 )
答案 0 :(得分:0)
您需要在模型列表中获取查询结果并返回Json:
var context = new YourContext();
var results = (from c in context.PCoulor select c).Contains(yourValue).ToList();
return Json(results , JsonRequestBehavior.AllowGet);