Код: Выделить всё
var result = (await db.Students
.Where(s => s.Name == "Foo")
.ToListAsync())
.Select(s => MySuperSmartMethod(s));
< /code>
MySuperSmartMethod, как я понял из этого ответа, вызывая метод Tolist () (и tolistasync () ), чтобы оценить будущие методы на стороне клиента: он сразу же запрашивает дату, итерации, и он ставит его в память. Asenumerable () вместо tolist () , потому что он не создает ненужный промежуточный список. Asenumerable () возвращает ienumerable , поэтому, когда речь заходит о выполнении будущих методов, они будут повторять объекты непосредственно в Ienumerable.
Код: Выделить всё
var result = db.Students
.Where(s => s.Name == "Foo")
.AsEnumerable()
.Select(s => MySuperSmartMethod(s));
< /code>
Ok, but now I have another problem: my method is not asynchronous anymore.
So, what should i do? Are there any other approaches? Does asynchronous querying database lead to any performance benefits in an ASP.NET Core application? Or should I rewrite my asynchronous MediatR queries and commands to synchronous replacing ToListAsync()Подробнее здесь: https://stackoverflow.com/questions/766 ... chronicity
Мобильная версия