Search code examples
c#asp.net-web-apibreeze-sharp

breeze.sharp - taskResult.Result - no response


I am stuck in a weird problem. When I query data using breeze client (c#), I get data fine in my unit test. When I call the same code from my webApi controller, it hangs on task.Result. Has anyone seen this behavior? Here is the code:

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

Solution

  • lokusking..you were right. " HERE " answered my question I did Task.Run( ).Result and that did it!. Don't have the option to mark your answer as the answer so writing it here. did mark it one up..which I could thanks much everyone.