-
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
6 changed files
with
47 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace AzureIdentityLivestream.Web.Services | ||
{ | ||
public record Person(string FirstName, string LastName, int Age); | ||
public record Person(int Id, string FirstName, string LastName, int Age); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/AzureIdentityLivestream.Web/Services/Sql/EfCorePersonProvider.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,18 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace AzureIdentityLivestream.Web.Services.Sql | ||
{ | ||
public class EfCorePersonProvider : IPersonProvider | ||
{ | ||
private readonly LivestreamContext _livestreamContext; | ||
|
||
public EfCorePersonProvider(LivestreamContext livestreamContext) | ||
{ | ||
_livestreamContext = livestreamContext; | ||
} | ||
|
||
public async Task<IEnumerable<Person>> GetPeople() => await _livestreamContext.People.ToListAsync(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/AzureIdentityLivestream.Web/Services/Sql/LivestreamContext.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,22 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace AzureIdentityLivestream.Web.Services.Sql | ||
{ | ||
public class LivestreamContext : DbContext | ||
{ | ||
public LivestreamContext([NotNull] DbContextOptions options) : base(options) | ||
{ | ||
} | ||
|
||
public DbSet<Person> People => Set<Person>(); | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder | ||
.Entity<Person>() | ||
.ToTable("Person") | ||
.HasKey(x => x.Id); | ||
} | ||
} | ||
} |
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