数据读取器不兼容类型的成员在数据读取器中没有同名的对应列

368yc8dk  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(217)

我有以下几点 stored-procedure 在一个 controller :

var insert_query = entities.Database.SqlQuery<Call_Info>("exec [dbo].[insert_call_info] @call_id, @user_id, @call_arrive, @call_end, @info", 
                    new SqlParameter("call_id", call_id),
                    new SqlParameter("user_id", u_id),
                    new SqlParameter("call_arrive", call_arrive),
                    new SqlParameter("call_end", call_end),
                    new SqlParameter("info", info)
                    ).ToList();

我正试着接通 POSTMAN 我得到以下错误:

"ExceptionMessage": "The data reader is incompatible with the specified 'EMSMVCModel.Call_Info'. A member of the type, 'call_id', does not have a corresponding column in the data reader with the same name.",
``` `Call_info.cs` 文件具有以下代码:

namespace EMSMVC.Models
{
using System;
using System.Collections.Generic;

public partial class Call_Info
{
    public int call_info_id { get; set; }
    public int call_id { get; set; }
    public string user_id { get; set; }
    public Nullable<System.DateTime> call_arrive { get; set; }
    public Nullable<System.DateTime> call_end { get; set; }
    public string info { get; set; }

    public virtual AspNetUser AspNetUser { get; set; }
    public virtual Call Call { get; set; }
}

}

call\u info表如下所示。 `call_info_id` 是一个自动递增字段,因此我不会通过存储过程添加值。

/******Object: Table [dbo].[Call_Info] Script Date: 25/5/2020 12:29:43 μ.μ.******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Call_Info](
[call_info_id] [int] IDENTITY(1,1) NOT NULL,
[call_id] [int] NOT NULL,
[user_id] nvarchar NOT NULL,
[call_arrive] [datetime] NULL,
[call_end] [datetime] NULL,
[info] nvarchar NULL,
PRIMARY KEY CLUSTERED
(
[call_info_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Call_Info] WITH CHECK ADD FOREIGN KEY([call_id])
REFERENCES [dbo].[Call] ([call_id])
GO

ALTER TABLE [dbo].[Call_Info] WITH CHECK ADD FOREIGN KEY([user_id])
REFERENCES [dbo].[AspNetUsers] ([Id])
GO

我有 `stored-procedure` . 

GET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[insert_call_info]
-- Add the parameters for the stored procedure here
@call_id int,
@user_id nvarchar(128),
@call_arrive datetime,
@call_end datetime,
@info nvarchar(255)
AS
BEGIN
SET FMTONLY OFF
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

INSERT INTO Call_info (call_id, user_id, call_arrive, call_end, info) VALUES (@call_id, @user_id, @call_arrive, @call_end, @info);
SELECT SCOPE_IDENTITY() AS call_info_id;

SET FMTONLY ON
END

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题