Skip to content

Instantly share code, notes, and snippets.

@ssougnez
Created June 8, 2018 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssougnez/6f63ace045cb5e4b28e9d174cacf3a74 to your computer and use it in GitHub Desktop.
Save ssougnez/6f63ace045cb5e4b28e9d174cacf3a74 to your computer and use it in GitHub Desktop.
string sql = $@"SELECT [Id] FROM [Drivers] WHERE [LastName] = 'Alonso';";
int driverId = (await connection.QueryAsync<int>(sql)).FirstOrDefault();
if (driverId != default)
{
sql = $"INSERT INTO [Tracks] ([Title], [BestLapTimeDriverId]) VALUES ('Belgium', @DriverId);";
await connection.ExecuteAsync(sql, new { DriverId = driverId });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment