Entity Framework 中的假查询
Fake query in Entity Framework
我们如何在ADO.Entity框架中拖放Fake查询过程
例如:我有SP
Select col into #temp from Table
错误:
Entity framework does not make the return type of this SP.
我也有类似的问题,我使用了以下方法。
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
现在在拖动 sp 注释之前的行
Select col into #temp from Table
select col from #temp
并在拖动 sp 后取消注释上面的行并注释下面的行
Declare @colName DataType
Select @colName as colName
这样 EF 会找到 return 类型。
注意 如果你的 SP returns 假设你必须声明 3 个变量而不是 select 这 3 个变量,那么这仅适用于一列变量作为列。
我们如何在ADO.Entity框架中拖放Fake查询过程
例如:我有SP
Select col into #temp from Table
错误:
Entity framework does not make the return type of this SP.
我也有类似的问题,我使用了以下方法。
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
现在在拖动 sp 注释之前的行
Select col into #temp from Table
select col from #temp
并在拖动 sp 后取消注释上面的行并注释下面的行
Declare @colName DataType
Select @colName as colName
这样 EF 会找到 return 类型。
注意 如果你的 SP returns 假设你必须声明 3 个变量而不是 select 这 3 个变量,那么这仅适用于一列变量作为列。