我遇到了一个奇怪的问题。当我使用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;
}
答案 0 :(得分:0)
lokusking ..你是对的。 &#34; HERE&#34;回答了我的问题 我做了Task.Run().Result并且做到了! 没有选择将答案标记为答案,所以在此写下来。确实标记了一次......我可以 非常感谢大家。