Skip to content

Instantly share code, notes, and snippets.

@ssougnez
Created June 8, 2018 13:28
Show Gist options
  • Save ssougnez/a93327f86fe595b498eb883477b3f540 to your computer and use it in GitHub Desktop.
Save ssougnez/a93327f86fe595b498eb883477b3f540 to your computer and use it in GitHub Desktop.
var hamilton = new Driver
{
FirstName = "Lewis",
LastName = "Hamilton",
ChampionTitleCount = 4
};
string sql = $@"INSERT INTO [Drivers] ([FirstName], [LastName], [ChampionTitleCount]) VALUES (@FirstName, @LastName, @ChampionTitleCount);
SELECT CAST(SCOPE_IDENTITY() AS int);";
hamilton.Id = (await connection.QueryAsync<int>(sql, hamilton)).FirstOrDefault();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment