I am using visual studio 2010 and with Entity Framework(EF). I am retriving data from database and binding into Gridview through Entity Model, using stored procedures. When I execute this Stored procedure in a SQL Query, its returns columns which is generated dynamically. ie., Execute (@PivotTableSQL). @PivotTableSQL contains dynamically generated select statement. Below is my code of the Stored procedure.
But, To create Complex Type, from the Entity model browser window -> Add Function import window -> Complex --> Get Columns Information, "The selected stored procedure return no columns." message is displayed. Please give me a solution, how to add function import and Get Column information (create complex Type) or any other alternate solution in detail. This one stopped my further development. Thanks in advance.
alter PROCEDURE spGetQuestGrid
(
@QID as int
)
AS
BEGIN
SET NOCOUNT OFF
SET FMTONLY OFF
Declare @optId varchar(10)
DECLARE @PivotColumnHeaders VARCHAR(MAX)
DECLARE @PivotTableSQL NVARCHAR(MAX)
set @optId = (select DISTINCT Optid from QuestOptions where QID = @QID)
SELECT @PivotColumnHeaders = COALESCE(@PivotColumnHeaders + ', [' + cast(Caption as varchar) + ']' ,
'[' + cast(Caption as varchar)+ ']')
FROM OptionsDetail where OptId = @optId
SET @PivotTableSQL = 'select * from (select Caption,Optid from OptionsDetail ) as datatable
PIVOT
( min(Optid) FOR Caption IN ( '+ @PivotColumnHeaders + '))as Colltable'
Execute (@PivotTableSQL)
END