-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/AzureIdentityLivestream.PeopleGenerator/SqlPeopleGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Dapper; | ||
using Microsoft.Data.SqlClient; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace AzureIdentityLivestream.PeopleGenerator | ||
{ | ||
public static class SqlPeopleGenerator | ||
{ | ||
public static async Task CreatePeople(IConfiguration configuration, IReadOnlyList<Person> people) | ||
{ | ||
await using var sqlConnection = new SqlConnection(configuration.GetValue<string>("SqlConnectionString")); | ||
|
||
foreach (var person in people) | ||
{ | ||
await sqlConnection.ExecuteScalarAsync( | ||
"INSERT INTO [dbo].[Person] ([FirstName], [LastName], [Age]) VALUES (@firstName, @lastName, @age)", | ||
new { person.FirstName, person.LastName, person.Age }); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"StorageConnectionString": "UseDevelopmentStorage=true" | ||
"StorageConnectionString": "UseDevelopmentStorage=true", | ||
"SqlConnectionString": "Data Source=(localdb)\\azureidentitylivestream; Initial Catalog=azure-identity-livestream; Integrated Security=SSPI" | ||
} |
18 changes: 18 additions & 0 deletions
18
src/AzureIdentityLivestream.PeopleGenerator/create-person-table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/****** Object: Table [dbo].[Person] Script Date: 17/02/21 14:24:52 ******/ | ||
SET ANSI_NULLS ON | ||
GO | ||
|
||
SET QUOTED_IDENTIFIER ON | ||
GO | ||
|
||
CREATE TABLE [dbo].[Person]( | ||
[Id] [int] IDENTITY(1,1) NOT NULL, | ||
[FirstName] [nvarchar](100) NOT NULL, | ||
[LastName] [nvarchar](100) NOT NULL, | ||
[Age] [int] NOT NULL, | ||
CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED | ||
( | ||
[Id] ASC | ||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] | ||
) ON [PRIMARY] | ||
GO |