I have the following stored procedure :
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SearchMediaTitles]
@query varchar(50),
@limit int = 6,
@userId int
AS
SET FMTONLY OFF
BEGIN
declare @searchString varchar(52)
set @searchString = '"' + @query +'*"'
IF @userId!=NULL
SELECT TOP (@limit) ID, Title from Media where CONTAINS([Title], @searchString)
AND ID IN
(
SELECT FavoriteMedia_ID
FROM dbo.UserMedia
WHERE UserMedia_Media_ID=@userId
)
ELSE
SELECT TOP (@limit) ID, Title from Media where CONTAINS([Title], @searchString)
END
In Entity Framework when I try to map it at function import for a complex type it says
the selected stored procedure returns no columns
I’ve read about this on the internet and I found out I need to set SET FMTONLY OFF, but as you can see it didn’t work.
Any ideas?
EDIT:
I’ve changed SELECT to * and it return an empty result. I think it’s related to problem described above
For everyone who has the same problem, this is what I’ve done.
First I modified the stored procedure to a simple one like this :
I imported it in
Entity Framework, created the complex type and mapping propertiesThen I changed it back and updated the model and now it works.
I think
Entity Frameworkhas some problems with complex stored procedures. From what I read it can’t get results for dynamic stored procedures or for a stored procedure which usetemp tables.PS: When I call it with Ajax, I call it using
data.column1 and data.column2. If I usedata.value' it returnsundefined` .It’s kinda weird.
EDIT: It’s like Martin said but I don’t know why it didn’t worked in the first place ! Thank you btw !