Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 18 additions & 25 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
<Project>

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<Configurations>Debug;Release</Configurations>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup>
<Description>Triggers for EF Core. Respond to changes in your ApplicationDbContext before and after they are committed to the database</Description>
<RepositoryType>Git</RepositoryType>
<RepositoryUrl>https://github.com/koenbeuk/EntityFrameworkCore.Triggered</RepositoryUrl>
<Authors>Koen Bekkenutte</Authors>
<PackageTags>EntityFramework;EFCore;Triggers;SQLServer;SqlLite;CosmosDb;.NET Core;aspnetcore</PackageTags>
<PackageProjectUrl>https://github.com/koenbeuk/EntityFrameworkCore.Triggered</PackageProjectUrl>
</PropertyGroup>

<PropertyGroup>
<EFCoreTriggeredVersion>3</EFCoreTriggeredVersion>
<EFCorePackageVersion>6.0.0</EFCorePackageVersion>
<MicrosoftExtensionsVersion>6.0.0</MicrosoftExtensionsVersion>
</PropertyGroup>
<PropertyGroup>
<Description>Triggers for EF Core. Respond to changes in your ApplicationDbContext before and after they are committed to the database</Description>
<RepositoryType>Git</RepositoryType>
<RepositoryUrl>https://github.com/koenbeuk/EntityFrameworkCore.Triggered</RepositoryUrl>
<Authors>Koen Bekkenutte</Authors>
<PackageTags>EntityFramework;EFCore;Triggers;SQLServer;SqlLite;CosmosDb;.NET Core;aspnetcore</PackageTags>
<PackageProjectUrl>https://github.com/koenbeuk/EntityFrameworkCore.Triggered</PackageProjectUrl>
</PropertyGroup>

<ItemGroup>
<None Include="$(SolutionDir)\README.md" Pack="true" PackagePath="\"></None>
</ItemGroup>
<ItemGroup>
<None Include="$(SolutionDir)\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
33 changes: 33 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.10" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.10" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
<PackageVersion Include="coverlet.collector" Version="8.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Verify.Xunit" Version="31.12.5" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="ScenarioTests.XUnit" Version="1.0.1" />
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions EntityFrameworkCore.Triggered.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.0.31710.8
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EDFABD48-3C79-47AE-B84C-47CE2A52C20D}"
ProjectSection(SolutionItems) = preProject
src\Directory.Build.props = src\Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0FAE4F6A-93BB-453C-8FB4-B24A9F30DA59}"
ProjectSection(SolutionItems) = preProject
test\Directory.Build.props = test\Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Items", "_Solution Items", "{CA7737C4-0D3C-4B81-B34C-B4812B54C018}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.props = Directory.Build.props
LICENSE.md = LICENSE.md
README.md = README.md
Directory.Packages.props = Directory.Packages.props
global.json = global.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkCore.Triggered.Abstractions", "src\EntityFrameworkCore.Triggered.Abstractions\EntityFrameworkCore.Triggered.Abstractions.csproj", "{B338AEB6-4D18-4069-AE00-9A1E33C638F4}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
Expand All @@ -12,8 +12,8 @@
<Configuration>Release</Configuration>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0-rc.1.21452.10" />
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\EntityFrameworkCore.Triggered\EntityFrameworkCore.Triggered.csproj" />
Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "10.0.100",
"rollForward": "latestMinor"
}
}
29 changes: 16 additions & 13 deletions samples/1 - HelloWorld/1 - HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>HelloWorld</RootNamespace>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EntityFrameworkCore.Triggered" Version="$(EFCoreTriggeredPackageVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(EFCorePackageVersion)" />
</ItemGroup>

</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>HelloWorld</RootNamespace>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\EntityFrameworkCore.Triggered\EntityFrameworkCore.Triggered.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace PrimarySchool.Triggers
{
public class StudentAssignRegistrationDate : IBeforeSaveTrigger<Student>
public class StudentAssignRegistrationDate : IBeforeSaveAsyncTrigger<Student>
{
public Task BeforeSave(ITriggerContext<Student> context, CancellationToken cancellationToken)
public Task BeforeSaveAsync(ITriggerContext<Student> context, CancellationToken cancellationToken)
{
if (context.ChangeType == ChangeType.Added)
{
Expand Down
29 changes: 16 additions & 13 deletions samples/2 - PrimarySchool/2 - PrimarySchool.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>PrimarySchool</RootNamespace>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EntityFrameworkCore.Triggered" Version="$(EFCoreTriggeredPackageVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(EFCorePackageVersion)" />
</ItemGroup>

</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>PrimarySchool</RootNamespace>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\EntityFrameworkCore.Triggered\EntityFrameworkCore.Triggered.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace PrimarySchool.Triggers
{
public class StudentSignupToMandatoryCourses : IBeforeSaveTrigger<Student>
public class StudentSignupToMandatoryCourses : IBeforeSaveAsyncTrigger<Student>
{
readonly ApplicationDbContext _applicationContext;

Expand All @@ -14,7 +14,7 @@ public StudentSignupToMandatoryCourses(ApplicationDbContext applicationContext)
_applicationContext = applicationContext;
}

public Task BeforeSave(ITriggerContext<Student> context, CancellationToken cancellationToken)
public Task BeforeSaveAsync(ITriggerContext<Student> context, CancellationToken cancellationToken)
{
var mandatoryCourses = _applicationContext.Courses
.Where(x => x.IsMandatory)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>StudentManager</RootNamespace>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EntityFrameworkCore.Triggered" Version="$(EFCoreTriggeredPackageVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="$(EFCorePackageVersion)" />
</ItemGroup>

</Project>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>StudentManager</RootNamespace>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\EntityFrameworkCore.Triggered\EntityFrameworkCore.Triggered.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace StudentManager.Triggers.Courses
{
public class AutoSignupStudents : IBeforeSaveTrigger<Course>
public class AutoSignupStudents : IBeforeSaveAsyncTrigger<Course>
{
readonly ApplicationDbContext _applicationContext;

Expand All @@ -15,7 +15,7 @@ public AutoSignupStudents(ApplicationDbContext applicationContext)
_applicationContext = applicationContext;
}

public async Task BeforeSave(ITriggerContext<Course> context, CancellationToken cancellationToken)
public async Task BeforeSaveAsync(ITriggerContext<Course> context, CancellationToken cancellationToken)
{
if (context.Entity.IsMandatory)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace StudentManager.Triggers.StudentCourses
{
public class BlockRemovalWhenCourseIsMandatory : IBeforeSaveTrigger<StudentCourse>
public class BlockRemovalWhenCourseIsMandatory : IBeforeSaveAsyncTrigger<StudentCourse>
{
readonly ApplicationDbContext _applicationContext;

Expand All @@ -14,7 +14,7 @@ public BlockRemovalWhenCourseIsMandatory(ApplicationDbContext applicationContext
_applicationContext = applicationContext;
}

public async Task BeforeSave(ITriggerContext<StudentCourse> context, CancellationToken cancellationToken)
public async Task BeforeSaveAsync(ITriggerContext<StudentCourse> context, CancellationToken cancellationToken)
{
if (context.ChangeType == ChangeType.Deleted)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace StudentManager.Triggers.StudentCourses
{
public class SendWelcomingEmail : IAfterSaveTrigger<StudentCourse>
public class SendWelcomingEmail : IAfterSaveAsyncTrigger<StudentCourse>
{
readonly ApplicationDbContext _applicationContext;
readonly EmailService _emailService;
Expand All @@ -16,7 +16,7 @@ public SendWelcomingEmail(ApplicationDbContext applicationContext, EmailService
_emailService = emailService;
}

public async Task AfterSave(ITriggerContext<StudentCourse> context, CancellationToken cancellationToken)
public async Task AfterSaveAsync(ITriggerContext<StudentCourse> context, CancellationToken cancellationToken)
{
var student = await _applicationContext.Students.FindAsync(new object[] { context.Entity.StudentId }, cancellationToken);
var course = await _applicationContext.Courses.FindAsync(new object[] { context.Entity.CourseId }, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace StudentManager.Triggers.Students
{
public class AssignRegistrationDate : IBeforeSaveTrigger<Student>
public class AssignRegistrationDate : IBeforeSaveAsyncTrigger<Student>
{
public Task BeforeSave(ITriggerContext<Student> context, CancellationToken cancellationToken)
public Task BeforeSaveAsync(ITriggerContext<Student> context, CancellationToken cancellationToken)
{
context.Entity.RegistrationDate = DateTime.Today;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace StudentManager.Triggers.Students
{
public class SignupToMandatoryCourses : IBeforeSaveTrigger<Student>
public class SignupToMandatoryCourses : IBeforeSaveAsyncTrigger<Student>
{
readonly ApplicationDbContext _applicationContext;

Expand All @@ -15,7 +15,7 @@ public SignupToMandatoryCourses(ApplicationDbContext applicationContext)
_applicationContext = applicationContext;
}

public async Task BeforeSave(ITriggerContext<Student> context, CancellationToken cancellationToken)
public async Task BeforeSaveAsync(ITriggerContext<Student> context, CancellationToken cancellationToken)
{
var mandatoryCourses = await _applicationContext.Courses
.Where(x => x.IsMandatory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace StudentManager.Triggers.Traits.Audited
{
public class CreateAuditRecord : IBeforeSaveTrigger<IAudited>
public class CreateAuditRecord : IBeforeSaveAsyncTrigger<IAudited>
{
private readonly ApplicationDbContext _applicationContext;

Expand All @@ -17,7 +17,7 @@ public CreateAuditRecord(ApplicationDbContext applicationContext)
_applicationContext = applicationContext;
}

public Task BeforeSave(ITriggerContext<IAudited> context, CancellationToken cancellationToken)
public Task BeforeSaveAsync(ITriggerContext<IAudited> context, CancellationToken cancellationToken)
{
var recordBuilder = new StringBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace StudentManager.Triggers.Traits.SoftDelete
{
class EnsureSoftDelete : IBeforeSaveTrigger<ISoftDelete>
class EnsureSoftDelete : IBeforeSaveAsyncTrigger<ISoftDelete>
{
readonly ApplicationDbContext _applicationContext;

Expand All @@ -15,7 +15,7 @@ public EnsureSoftDelete(ApplicationDbContext applicationContext)
_applicationContext = applicationContext;
}

public Task BeforeSave(ITriggerContext<ISoftDelete> context, CancellationToken cancellationToken)
public Task BeforeSaveAsync(ITriggerContext<ISoftDelete> context, CancellationToken cancellationToken)
{
if (context.ChangeType == ChangeType.Deleted)
{
Expand Down
Loading
Loading