asp.net - 邮递员发布请求响应带有空参数
问题描述
我正在尝试通过使用 Service 类中的 ExecuteSqLRaw() 来执行将值插入表的存储过程。
public Category AddCategory(Category category)
{
db.Database.ExecuteSqlRaw("[dbo].[CatinsertSP] {0},{1},{2},{3},{4},{5},{6},{7}", category.CategoryId, category.CategoryCode, category.CategoryName, category.AboutCategory, category.ParentCategoryId, category.IsEnable, category.IsActive, category.IsBlock);
return category;
}
这是 Postman { "Category_Code":"130", "Category_Name":"Kids" } 中的请求正文
这是状态为 200 { "categoryId": "00000000-0000-0000-0000-000000000000", "categoryCode": null, "categoryName": null, "aboutCategory": null, "parentCategoryId": null, "isEnable “:空,“isActive”:空,“isBlock”:空,“updateLog”:空,“createdOn”:空,“createdBy”:空,“updateOn”:空,“updateBy”:空,“seqNo”: 0, "module": [], "product": [] } 这是存储过程
ALTER PROCEDURE [dbo].[CatinsertSP]
-- Add the parameters for the stored procedure here
@Category_Id uniqueidentifier ,
@Category_Code nvarchar(20),
@Category_Name nvarchar(167),
@About_Category nvarchar(max),
@Parent_Category_Id uniqueidentifier,
@Is_Enable bit,
@Is_Active bit,
@Is_Block bit
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into [dbo].[Category] (Category_Id,Category_Code,Category_Name,About_Category,Parent_Category_Id,Is_Enable,Is_Active,Is_Block) values(newid(),@Category_Code,@Category_Name,@About_Category,@Parent_Category_Id,@Is_Enable,@Is_Active,@Is_Block)
select * from Category where Category_Id=@Category_Id
END
Go
这是控制器代码`
[HttpPost]
public ActionResult<Category> AddCategory([FromBody]Category category)
{
return _service.AddCategory(category);
}
我不明白问题出在邮递员还是在调用存储过程?我是新手,请帮忙。
解决方案
推荐阅读
- web-scraping - 如何以定义的术语分解字符向量?
- c - switch语句c语言的问题
- laravel - 使用 AlpineJS 和 @entangle 指令在 Livewire 中嵌套组件
- python - 如何修复 UnboundLocalError:分配前引用的局部变量 'o1'
- python - 用python中的公共子字符串连接字符串?
- node.js - 在网站上使用nodejs在线
- javascript - 我似乎找不到 DiscordAPIError: Unknown Message 的解决方案
- sql - 在 SQL 中的日期之间每天计算用户保留率
- python - 无法为 form_valid 绑定 ForeignKey
- flutter - 如何在颤振画布中绘制pdf内容