Let me try to answer your questions and clear up some misunderstandings. First, I assume the context is Entity Framework and working with data from a database.
The line of code you shared is a LINQ (Language-Integrated Query) method that accepts a lambda expression. LINQ also has SQL-like Query Syntax (from x in y select z) but both are LINQ. Both LINQ method syntax and SQL-like syntax are converted into regular old SQL and sent to the database for processing.
You can even have different SQL providers which affects the resulting SQL.
Overview: https://learn.microsoft.com/en-us/dotnet/csharp/linq/
LINQ Tips: https://www.youtube.com/watch?v=71qFZUyKCy0
Since you are looking for 'low-level' querying, here is how you can see the SQL being generated:
Starting with EF Core 5.0, you can call .ToQueryString() directly on any LINQ query variable. This returns the generated SQL string immediately without executing the query against the database.
You can also configure EF Core to write every SQL statement it executes to your console or debug window. This is done in your DbContext configuration:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// Logs SQL to the Console
optionsBuilder.LogTo(Console.WriteLine);
// OR: Logs SQL to the Visual Studio Debug Output window
// optionsBuilder.LogTo(msg => System.Diagnostics.Debug.WriteLine(msg));
}
- Guide on Logging: https://www.youtube.com/watch?v=xy_yBZ3nwXg
Finally, if you are using Visual Studio, you can hover over a query variable while debugging and expand the DebugView property to see the SQL string without writing any extra code.