2015-01-13 3 views

ответ

0

I также была аналогичная проблема, я использовал следующий подход.

First write your SP and than declare as many variables as your SP will return columns at end of sp and than write a select statement which will select all variables as columns hence EF will find return type of SP. Before dragging SP comment out the actual code of sp and only write the select statement. When you have dragged the SP comment the select statement written at end and ucomment actual code of SP.

Пример

Create Procedure TestSP 
Select col into #temp from Table 
select col from #temp 
//This is fake Query 
Declare @colName DataType 
Select @colName as colName 

Теперь перед перетаскиванием зра комментария следующих строк

Select col into #temp from Table 
select col from #temp 

И после того, как перетаскивание зра раскомментируйте вышеуказанные строки и комментарии следующих строк

Declare @colName DataType 
Select @colName as colName 

Таким образом, EF найдет тип возврата.

ПРИМЕЧАНИЕ Это только для одного столбца, если ваш SP возвращается, скажем, 3 столбца, которые вы должны объявить 3 переменными, и выберите эти 3 переменные в качестве столбцов.

Смежные вопросы