c# - 在 .NET Core 2.2 中从 UI 执行存储过程时出现 TimeoutException
问题描述
我需要在等待操作之后执行存储过程。我目前正在使用 EF 执行存储过程_dbContext.Database.ExecuteSqlCommand
。
我在 Web API 解决方案中编写了该功能。当我从 POSTMAN 调用 Web API 时,它成功执行了该过程,没有任何问题。
但是当我尝试从我的 UI 界面执行该过程时,它会引发“超时异常”。
public async void ProcessEmployeeDetailsAsync(XmlDocument xmlContent)
{
// Some Business logic
if (_dbContext.Entry(EmployeeBatch).State == EntityState.Modified)
{
var recordCount = await _dbContext.SaveChangesAsync();
if (recordCount > 0)
{
SqlParameter EmpBatchId = new SqlParameter("@IPV_EmployeeBatchId", batchId);
_dbContext.Database.ExecuteSqlCommand(
"exec uspEmployeeBatchValidation_BatchId @IPV_BatchId",
EmpBatchId); // TimeOutException occuring
}
}
}
启动.cs
services.AddDbContextPool<EmployeeContext>((serviceProvider, optionBuilder) =>
{
optionBuilder
.UseLazyLoadingProxies()
.UseSqlServer(_Configuration.GetConnectionString("EmployeeContext"));
});
谁能帮我在我失踪的地方?因为我是异步编程的新手。
解决方案
推荐阅读
- r - 通过任何输入更改下载按钮自动清除
- javascript - 使用来自 componentDidMount React 中的 fetch 的属性渲染组件
- .net - 本地计算机上的 windows Service 服务启动然后停止
- wordpress - .htaccess 在 bitnami wordpress 中的位置
- mysql - 如何直接在 MySQL Workbench 中编辑值?
- tcl - 在 TCL 语言中理解正则表达式有困难
- javascript - 使用graphql查询检查反应js中的空对象
- php - 如何每天自动运行php文件
- javascript - 未捕获(承诺中)错误:使用 Laravel 请求失败,状态码 404
- javascript - 在 JavaScript 中根据 id 属性合并两个对象