sagesky36
sagesky36

Reputation: 4692

Cannot await 'System.collections.Generic.List<AnonymousType#1>

I'm using Entity Framework 6.1 within a WEB API project and am simply trying to pass a collection back but am getting the above subject line error.

In addition, there is no ToListAsync() method available in the intellisense.

The design time compile error is immediately over the await statement.

How can I correct the above subject error and also have the ToListAsync method available?

Here are my code snippets:

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

List<HH_FuelTkt_Output> tkts = await DbContext.HH_FuelTkt.Select(s =>
                            new
                            {
                                s.Customer_Name,
                                s.FuelTkt_ID,
                                s.Image_ID,
                                s.Ticket_No,
                                s.Trans_Timestamp,
                                s.Vehicle_No
                            }
                            ).ToList();

Upvotes: 0

Views: 4241

Answers (1)

milagvoniduak
milagvoniduak

Reputation: 3254

There is ToListAsync http://msdn.microsoft.com/en-us/library/dn220262(v=vs.113).aspx

Namespace: System.Data.Entity

Assembly: EntityFramework (in EntityFramework.dll)

Do you have using for System.Data.Entity? ToListAsync is an extension method.

Upvotes: 1

Related Questions