为什么JSON不接受将变量作为Id传递的存储过程?

时间:2021-07-28 02:45:03

Here I write a stored procedure for deleting records; it's working fine in SQL. But when I try to load it in MVC JSON format it threw an error:

这里我写了一个用于删除记录的存储过程;它在SQL中运行良好。但是当我尝试以MVC JSON格式加载它时,它会抛出一个错误:

implementation of the query pattern for source type 'int'. 'Select' not found"

源类型'int'的查询模式的实现。 '选择'未找到“

Stored procedure:

ALTER procedure [dbo].[AccessorDataDelById]
    @ID int
AS
BEGIN
    DELETE FROM Accessors
    WHERE Id = @ID
END

JSON format:

public JsonResult GetAssdata(int iD = 0)
{
    var x = (from n in db.AccessorDataDelById(iD)
             select n).FirstOrDefault();

    return new JsonResult { Data = x, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}

1 个解决方案

#1


1  

var x=db.AccessorDataDelById(iD)

#1


1  

var x=db.AccessorDataDelById(iD)