I am using Entity Framework 4 and we have a bunch of stored procedures in our model. Currently we can do everything we need. However we have a new procedure that takes a string, and ultimately performs something such as
Create Procedure usp_RunSearch
@searchTerm VARCHAR(2000)
AS
BEGIN
DECLARE @sql VARCHAR(4000)
SET @sql = '
SELECT ID,
NAME
FROM Users'
IF(ISNULL(@searchTerm, '') != '')
BEGIN
SET @sql = @sql + 'WHERE ' + @searchTerm
END
Exec (@sql)
END
to return the result-set.
EF does not seem to be able to interrogate this procedure to get the resultant column list.
Is there anything i can do to help EF get over this hurdle?
In the end i have created a ComplexType by hand in the EDMX and setup the function import for the stored procedure to use this manually defined complex type. I think that when EF inspects the sproc it can’t figure the return set of columns, even though the select list is relatively static in my example.