Difference between “ToListAsync()” and “AsAsyncEnumerable().ToList()”
问题 Function need to return Task<List<Record>> Following both options are returning Task<List<Record>> , which one is more efficient? Is there any standard way here? Option 1 : Task<List<Record>> GetRecords() { return DbContext.Set<Record>.Where(predicate).ToListAsync(); } Option 2: Task<List<Record>> GetRecords() { return DbContext.Set<Record>.Where(predicate).AsAsyncEnumerable().ToList(); } 回答1: Go for option 1 ToListAsync as the source code of AsAsyncEnumerable explicitly mentions This is an