0

I'm using Entity Framework 6.1 and am getting the above subject line error. The design time compile error is on the second line starting with the await.

How come I cannot await the SqlQuery? If I remove the await, the clause is fine.

I have the below code snippets:

public async Task<IEnumerable<HH_FuelTkt_Output>> GetFilteredFuelTicketsAsync(HH_FuelTkt_Input value)

var fto = await DbContext.HH_FuelTkt.SqlQuery("SELECT * from HH");
1
  • How do you consume fto? (that's where you'd be applying the async mechanics) Commented Apr 29, 2014 at 17:22

2 Answers 2

1

SqlQuery() doesn't return a Task, so you can't await it.

SqlQuery.ToListAsync(), however, does return a Task and can be awaited.

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

2 Comments

If I include SQL inside the SqlQuery, is it pre-compiled after it executes once like a stored procedure?
I don't know the answer to that one, sorry.
1

DbSet.SqlQuery does not return a Task and is thus not awaitable.

Comments

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.