asp.net-mvc - 当我尝试在asp.net mvc中导入存储过程时,选定的存储过程不返回任何列

标签 asp.net-mvc entity-framework asp.net-mvc-5 edmx

我在SQL Server 2008 R2和ASP.NET MVC Web应用程序中有以下存储过程:-

USE [ITSERres]
GO
/****** Object:  StoredProcedure [dbo].[AdvanceSearchSP]    Script Date: 08/04/2014 16:21:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  StoredProcedure [dbo].[AdvanceSearch2]    Script Date: 07/18/2014 10:37:47 ******/


ALTER PROCEDURE [dbo].[AdvanceSearchSP]
        -- Add the parameters for the stored procedure here

        @SearchType nvarchar(10) = null,
        @CustomerID bigint = null,
        @StringCustomerID nvarchar(50) = null,
        @SiteID bigint = null,
        @StateID bigint = null,
        @PrimarycustomerOnly bit = false,
        @RoleID int = null,
        @TypeID int = null,
        @IsManaged bit = null,
        @Name nvarchar(125) = null,
        @NameSelection nvarchar(10) = null,
        @Tag nvarchar(50) = null,
        @TagSelection nvarchar(10) =null,
        @ServiceTag nvarchar(100) = null,
        @ServiceTagSelection nvarchar(10) =null,
        @SerialNumber nvarchar(50) = null,
        @SerialNumberSelection nvarchar(10) =null,
        @Comment nvarchar(250) = null,
        @CommentSelection nvarchar(10) =null,
        @IP nvarchar(50) = null,
        @IPSelection nvarchar(10) = null,
         @MAC nvarchar(50) = null,
         @MACSelection nvarchar(10) = null
    AS
    BEGIN

        SET NOCOUNT ON;
if(@SearchType = 'name')
Begin 
        -- Insert statements for procedure here
    select t.Tag , r.RESOURCENAME , rs.DISPLAYSTATE as StateName, tt.Name as TypeName , sdo.NAME as sitename , accountdef.ORG_NAME as cusotmername, t.IsManaged as ismanaged ,sysinfo.SERVICETAG,r.SERIALNO
  //code goes here...

我做了以下事情:
  • 我将SP insdie映射到我的.edmx文件。
  • 我右键单击.edmx文件,然后单击“模型浏览器”。
  • 在我的模型下的
  • ,我单击功能导入。
  • 我在SP上单击鼠标右键,然后单击“编辑”。
    然后,当我单击“获取列信息”时,出现以下消息:-

  • The selected stored procedure returns no columns



    有人可以建议吗?
    谢谢

    最佳答案

    我也面临同样的问题。仅供引用,我的存储过程包含临时表。
    搜寻了一下之后,发现此页面解决了我的问题:

    http://forums.asp.net/t/2000731.aspx?EF+4+0+The+selected+stored+procedure+returns+no+columns+when+i+try+to+import+my+stored+procedure+inside+my+asp+net+mvc

    建议的解决方案是在存储过程的开头添加SET FMTONLY OFF
    对于我的情况,它是完美的。

    也许您可以尝试一下。

    关于asp.net-mvc - 当我尝试在asp.net mvc中导入存储过程时,选定的存储过程不返回任何列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25122642/

    相关文章:

    asp.net-mvc - Firefox 中 ASP.Net MVC 中的压缩过滤器属性出现问题

    c# - 如何在不知道 MIME 类型的情况下在 ASP.NET 中返回 FileResult?

    c# - 停止 Visual Studio 将数据库 MDF 复制到 bin

    c# - 找不到类型或命名空间名称 'Column'

    c# - BAL 中的依赖注入(inject)而不添加对 DAL 的项目引用

    c# - AspNetUsers (Identity) 和自定义表之间的一对多关系

    asp.net-mvc - 我应该如何链接到 ASP.NET MVC 5 中的用户配置文件页面?

    c# - 有没有办法关闭 Hangfire 使用 serilog 进行的日志记录?

    c# - OnAuthorization 中的 MVC 重定向导致授权失败

    c# - _Layout.cshtml不能直接请求,因为调用了 "RenderBody"方法