-3

I have a stored procedure I have written which simply queries the DB and returns the rows. I incorporated it into my .NET project through the use of the Entity Framework and through my database context I have complete access to the query. The issue I face is that I have to use async-await to pass the results but I am not sure what to add to my command for this to execute correctly?

Also an error I notice appearing under my the execution line when I add "await" is : int' does not contain a definition for 'getawaiter'

        /**Search**/
        // POST: api/postsearch
        [System.Web.Http.HttpPost, System.Web.Http.Route("postsearch")]
        public async Task<IHttpActionResult> PostSearch(string value)
        {
            var _ot = _output.searchLog(value);
           return Ok(_ot);
        }
2
  • And what is _output.searchLog? Commented May 6, 2019 at 15:17
  • That is the name of my _output is my db context and searchLog is my stored procedure. Commented May 6, 2019 at 15:19

1 Answer 1

0

Your asynch decorator is sufficient, however, this will not increase your efficiency. You still have to wait for the Web API to return the object, no matter what. You should make sure all your lower-level methods are also asynch, of course. I saw another post that explained that it would be wisest to increase the User Experience of the UI by writing that code to APPEAR more efficient, but you must wait for the results, because you want the asynch. Period. End of sentence.

More information at this post:

Effectively use async/await with ASP.NET Web API

Sign up to request clarification or add additional context in comments.

1 Comment

I also noticed one of the errors that appear under the line executing the stored proc when I add "Await" is int' does not contain a definition for 'getawaiter'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.