breeze.sharp - taskResult.Result - 没有回应

时间:2016-08-19 21:24:37

标签: c# asp.net-web-api breeze-sharp

我遇到了一个奇怪的问题。当我使用breeze客户端(c#)查询数据时,我的单元测试中的数据正常。当我从webApi控制器调用相同的代码时,它挂起在task.Result上。有没有人见过这种行为? 这是代码:

// This method when called from unit test works fine, but not from webApi:

public IEnumerable<ProductBaseInformation> GetProductBaseInformation()
    {
        var result = GetAllProductBaseInformation();
        var productBase = result.Result; // GETS STUCK HERE..CODE NOT GOING FURTHER...
        return productBase;
    }  

    private async Task<IEnumerable<ProductBaseInformation>> GetAllProductBaseInformation()
            {
              _entityQuery = new EntityQuery<ProductBaseInformation>();

              var products = await _entityManager.ExecuteQuery(_entityQuery);

            return (IEnumerable<ProductBaseInformation>)products;
    }

1 个答案:

答案 0 :(得分:0)

lokusking ..你是对的。 &#34; HERE&#34;回答了我的问题 我做了Task.Run().Result并且做到了! 没有选择将答案标记为答案,所以在此写下来。确实标记了一次......我可以 非常感谢大家。