。NetCore 2.2中从UI执行存储过程时发生TimeoutException

问题描述 投票:0回答:1

我需要在等待操作之后执行存储过程。我当前正在使用EF _dbContext.Database.ExecuteSqlCommand执行存储过程。目前,我在WebApi解决方案中编写了该功能。当我从POSTMAN调用WebApi时,它成功执行了proc,没有任何问题。

但是当我尝试从UI界面执行Proc时。它抛出Time Out Exception

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
         }
    }
}

Startup.cs

services.AddDbContextPool<EmployeeContext>((serviceProvider, optionBuilder) =>
            {
                optionBuilder
                    .UseLazyLoadingProxies()
                    .UseSqlServer(_Configuration.GetConnectionString("EmployeeContext"));
            });

有人可以在我想念的地方帮我吗?由于我是异步编程的新手,所以]

我需要在等待操作之后执行存储过程。我当前正在使用EF _dbContext.Database.ExecuteSqlCommand执行存储过程。目前我写了...

c# entity-framework asp.net-core .net-core async-await
1个回答
0
投票

也许UI应用程序无法连接到数据库。您是否在同一台计算机上运行Web API和UI?您正在使用Windows身份验证吗?如果是这样,您是否在同一用户下运行WEB API和UI?

© www.soinside.com 2019 - 2024. All rights reserved.