sagesky36
sagesky36

Reputation: 4692

cannot await 'system.data.entity.infrastructure.dbsqlquery

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");

Upvotes: 0

Views: 487

Answers (2)

Jason P
Jason P

Reputation: 27012

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

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

Upvotes: 1

Tim
Tim

Reputation: 15237

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

Upvotes: 1

Related Questions