Add example scalar query.

This commit is contained in:
Kevin Matsubara 2025-04-08 22:24:28 +02:00
parent 99edd6c536
commit 093c663b31

View File

@ -16,7 +16,17 @@ context.Database.EnsureCreated();
// Rather than raise: "System.InvalidOperationException: Sequence contains no elements."
// var firstCoach = await context.Coaches.FirstOrDefaultAsync();
await RawSQLStatement();
async Task QueryScalarType()
{
// Query a scalar or non-entity type.
// Scalar subqueries or scalar queries are queries that return exactly one column and one or zero records.
// Source: https://stackoverflow.com/questions/20424966/what-is-a-scalar-query
var leagueIds = context.Database.SqlQuery<int>(
$"SELECT Id FROM Leagues"
).ToList();
}
async Task RawSQLStatement()
{