-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow applications to use their own db context (#5)
* get JsonSerializerOptions from CrdtConfig, freeze CrdtConfig once it's used to provide json options. * extract CrdtDbContext into an interface so the DbContext can be defined in the application * refactor sample project to define it's own dbcontext * add some comments about why we freeze the builders, and interpolate some values, including the type name when trying to add to a frozen builder. * add some obsolete attributes, simplify ICrdtDbContext interface * simplify linq2db setup * delete CrdtDbContext.cs rather than marking it obsolete
- Loading branch information
Showing
16 changed files
with
297 additions
and
231 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
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,19 @@ | ||
using Crdt.Changes; | ||
using Crdt.Core; | ||
using Crdt.Db; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Crdt.Sample; | ||
|
||
public class SampleDbContext(DbContextOptions<SampleDbContext>options, IOptions<CrdtConfig> crdtConfig): DbContext(options), ICrdtDbContext | ||
{ | ||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.UseCrdt(crdtConfig.Value); | ||
} | ||
|
||
public DbSet<Commit> Commits => Set<Commit>(); | ||
public DbSet<ChangeEntity<IChange>> ChangeEntities => Set<ChangeEntity<IChange>>(); | ||
public DbSet<ObjectSnapshot> Snapshots => Set<ObjectSnapshot>(); | ||
} |
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
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
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
Oops, something went wrong.