SShortSingh.
Back to feed

Why LINQ Has ToListAsync but No WhereAsync: The Async Execution Explained

0
·5 views

In Entity Framework Core, LINQ operators like Where, Select, and OrderBy do not execute database queries — they only build an expression tree describing what to fetch. Actual database communication happens only at terminal operators such as ToList, Count, or First, which is precisely why EF Core provides async versions of those operators and not the query-building ones. Developers can also use AsAsyncEnumerable() to process large result sets row by row without loading everything into memory, leveraging C# 8's IAsyncEnumerable. A common pitfall is using Task.Run with synchronous ToList, which still blocks a thread pool thread rather than releasing the thread during I/O as true async methods do. Additionally, DbContext is not thread-safe, so running multiple async queries concurrently on the same context instance can cause dangerous race conditions.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Developer Shares Open Java Practice Problem Repository on GitHub

A developer has published a collection of Java practice problems they have solved, making the repository publicly available on GitHub under the name MyJavaExercises. The project is intended as a learning resource for others interested in Java programming. The author plans to continue adding new problems to the repository over time. Visitors are also encouraged to suggest more accurate or optimized solutions to existing problems.

0
ProgrammingDEV Community ·

Why HTTP/3 Replaced TCP with QUIC to Fix Web Protocol Bottlenecks

HTTP/3 is the latest version of the web's core data transfer protocol, built to address fundamental limitations in its predecessor HTTP/2. While HTTP/2 improved on HTTP/1.1 by enabling multiple streams over a single TCP connection, it still suffered from head-of-line blocking — where a lost packet stalls all streams sharing that connection. HTTP/3 resolves this by replacing TCP with QUIC, a transport protocol that runs over UDP and handles streams independently, so one lost packet no longer delays unrelated data. QUIC also reduces connection setup time and supports smoother network migration, such as switching from Wi-Fi to mobile data. The core HTTP semantics — methods, status codes, headers, and caching — remain unchanged; only the underlying transport layer is different.

0
ProgrammingGitHub Blog ·

GitHub AI Security Agent Uncovers 24 Vulnerabilities in Android Apps

GitHub researchers used an open-source AI-powered security agent to identify 24 vulnerabilities in Android applications. The findings were made possible through targeted AI task flows designed to detect critical security flaws. The team has detailed the specific bugs uncovered during the process, highlighting the agent's effectiveness in automated vulnerability discovery. GitHub has also made the tool publicly available, allowing developers to run the same security agent on their own Android applications.

0
ProgrammingDEV Community ·

Developer builds open-source fuzzy search library inside PostgreSQL without schema changes

A software developer built an open-source PHP library called Fuzzphony to enable forgiving, typo-tolerant search within an existing PostgreSQL database after being unable to modify the schema or add new infrastructure like Elasticsearch. The library leverages built-in PostgreSQL features — full-text search via tsvector and tsquery, the unaccent extension, and pg_trgm trigram similarity — to handle typos, accent variations, and word stemming. Fuzzphony maintains its own shadow index tables alongside the original data, avoiding any changes to production schemas. The library supports ranked results, field weighting, filter columns, query exclusions, and user-input sanitisation, with warnings returned for malformed queries. Currently at version 0.4 and under active development, Fuzzphony is open source with a stable core but an API that may change before the 1.0 release.