Skip to content

Commit

Permalink
Merge pull request #70 from WeihanLi/dev
Browse files Browse the repository at this point in the history
9.1.0 preview 1
  • Loading branch information
WeihanLi authored Jan 12, 2025
2 parents 1fe6d30 + 4efc368 commit fac7df1
Show file tree
Hide file tree
Showing 25 changed files with 459 additions and 149 deletions.
17 changes: 0 additions & 17 deletions .github/stale.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
dotnet-version: 9.0.x
- name: dotnet info
run: dotnet --info
- name: build
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
include-prerelease: true
dotnet-version: 9.0.x
- name: build
run: dotnet build
- name: format
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release
on:
workflow_dispatch:
push:
branches: [ master ]
jobs:
build:
name: Release
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Build
shell: pwsh
run: .\build.ps1 --stable=true
- name: Get Release Version
shell: pwsh
run: dotnet-exec https://github.com/OpenReservation/scripts/blob/main/build/export-gh-release-version.cs
- name: create release
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ env.ReleaseVersion }} --generate-notes --target master (Get-Item ./artifacts/packages/*.nupkg)
10 changes: 5 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project>
<Import Project="./build/sign.props" />
<Import Project="./build/version.props" />

<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<CommonVersion>1.0.66</CommonVersion>
<EFVersion>8.0.6</EFVersion>
<CommonVersion>1.0.74</CommonVersion>
<EFVersion>9.0.0</EFVersion>

<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand All @@ -20,6 +20,6 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryUrl>https://github.com/WeihanLi/WeihanLi.EntityFramework</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Copyright>Copyright 2019-2024 (c) WeihanLi</Copyright>
<Copyright>Copyright 2019-$([System.DateTime]::Now.Year) (c) WeihanLi</Copyright>
</PropertyGroup>
</Project>
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@

## Intro

EntityFramework extensions
[EntityFrameworkCore](https://github.com/dotnet/efcore) extensions

## Package Release Notes

See PRs for details
See Releases/PRs for details

https://github.com/WeihanLi/WeihanLi.EntityFramework/pulls?q=is%3Apr+is%3Aclosed+is%3Amerged+base%3Amaster
- Releases: https://github.com/WeihanLi/WeihanLi.EntityFramework/releases
- PRs: https://github.com/WeihanLi/WeihanLi.EntityFramework/pulls?q=is%3Apr+is%3Aclosed+is%3Amerged+base%3Amaster

> Package Versions
>
> For EF Core 2.x , use 1.4.x and below
> For EF 8 and above, use 8.x or above major-version matched versions
>
> For EF Core 3.x, use 1.5.0 above, and 2.0.0 below
> For EF 7, use 3.x
>
> For EF Core 5/6, use 2.x
>
> For EF 7, use 3.0.0 and above
> For EF Core 3.x, use 1.5.0 above, and 2.0.0 below
>
> For EF 8 and above, use 8.x or above major-version matched versions
> For EF Core 2.x , use 1.4.x and below
## Features

Expand All @@ -51,14 +52,14 @@ https://github.com/WeihanLi/WeihanLi.EntityFramework/pulls?q=is%3Apr+is%3Aclosed

- AutoUpdate

- Soft delete for specific entity
- Soft delete for the specific entity
- Auto update CreatedAt/UpdatedAt/CreatedBy/UpdatedBy

- Extensions

- Update specific column(s) `Update`
- Update without specific column(s) `UpdateWithout`

## Contact
## Support

contact me <weihanli@outlook.com> if you need
Feel free to try and [create issues](https://github.com/WeihanLi/WeihanLi.EntityFramework/issues/new) if you have any questions or integration issues
15 changes: 15 additions & 0 deletions WeihanLi.EntityFramework.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeihanLi.EntityFramework.Te
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{A1756F80-F25E-4ADC-A079-048FFCA5DBA6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeihanLi.EntityFramework.SourceGenerator", "src\WeihanLi.EntityFramework.SourceGenerator\WeihanLi.EntityFramework.SourceGenerator.csproj", "{010A98BE-1871-4E6F-8129-7A1C44C73423}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -61,6 +63,18 @@ Global
{9DF6D464-63A7-487C-9763-4A212ADDFC4B}.Release|x64.Build.0 = Release|Any CPU
{9DF6D464-63A7-487C-9763-4A212ADDFC4B}.Release|x86.ActiveCfg = Release|Any CPU
{9DF6D464-63A7-487C-9763-4A212ADDFC4B}.Release|x86.Build.0 = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|Any CPU.Build.0 = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|x64.ActiveCfg = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|x64.Build.0 = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|x86.ActiveCfg = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Debug|x86.Build.0 = Debug|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|Any CPU.ActiveCfg = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|Any CPU.Build.0 = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|x64.ActiveCfg = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|x64.Build.0 = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|x86.ActiveCfg = Release|Any CPU
{010A98BE-1871-4E6F-8129-7A1C44C73423}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -69,6 +83,7 @@ Global
{0BB1C3F3-50C6-4924-894C-0A9A7BA4E54A} = {40B7673F-5ACD-42E4-AE04-6C3AEEBC8546}
{0E013C55-6D52-4B68-B188-460B97DB1E48} = {46AED92E-94FC-409A-9CFB-C9CD4E59717D}
{9DF6D464-63A7-487C-9763-4A212ADDFC4B} = {A1756F80-F25E-4ADC-A079-048FFCA5DBA6}
{010A98BE-1871-4E6F-8129-7A1C44C73423} = {40B7673F-5ACD-42E4-AE04-6C3AEEBC8546}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {201A8B4F-A16D-44B7-BB29-F9B9CFC2A467}
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ steps:
displayName: 'Use .NET sdk'
inputs:
packageType: sdk
version: 8.0.x
version: 9.0.x
includePreviewVersions: true

- script: dotnet --info
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[string]$SCRIPT = '.\build\build.cs'

# Install dotnet tool
dotnet tool install --global dotnet-execute
dotnet tool update --global dotnet-execute

Write-Host "dotnet-exec $SCRIPT --args $ARGS" -ForegroundColor GREEN

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SCRIPT='./build/build.cs'

# Install tool
dotnet tool install --global dotnet-execute
dotnet tool update --global dotnet-execute
export PATH="$PATH:$HOME/.dotnet/tools"

echo "dotnet-exec $SCRIPT --args=$@"
Expand Down
10 changes: 5 additions & 5 deletions build/build.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var target = CommandLineParser.Val("target", "Default", args);
var apiKey = CommandLineParser.Val("apiKey", "", args);
var stable = CommandLineParser.Val("stable", null, args).ToBoolean();
var noPush = CommandLineParser.Val("noPush", null, args).ToBoolean();
var target = CommandLineParser.Val("target", args, "Default");
var apiKey = CommandLineParser.Val("apiKey", args);
var stable = CommandLineParser.BooleanVal("stable", args);
var noPush = CommandLineParser.BooleanVal("noPush", args);
var branchName = EnvHelper.Val("BUILD_SOURCEBRANCHNAME", "local");

var solutionPath = "./WeihanLi.EntityFramework.sln";
Expand Down Expand Up @@ -112,4 +112,4 @@ async Task ExecuteCommandAsync(string commandText, KeyValuePair<string, string>[
var result = await CommandExecutor.ExecuteCommandAndOutputAsync(commandText);
result.EnsureSuccessExitCode();
Console.WriteLine();
}
}
7 changes: 0 additions & 7 deletions build/sign.props

This file was deleted.

6 changes: 3 additions & 3 deletions build/version.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<VersionMajor>8</VersionMajor>
<VersionMinor>0</VersionMinor>
<VersionPatch>7</VersionPatch>
<VersionMajor>9</VersionMajor>
<VersionMinor>1</VersionMinor>
<VersionPatch>0</VersionPatch>
<VersionRevision>0</VersionRevision>
<VersionPrefix Condition="'$(VersionRevision)'=='0' or '$(VersionRevision)'==''">$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
<VersionPrefix Condition="'$(VersionRevision)'!='0'">$(VersionMajor).$(VersionMinor).$(VersionPatch).$(VersionRevision)</VersionPrefix>
Expand Down
Binary file removed build/weihanli.snk
Binary file not shown.
5 changes: 5 additions & 0 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes

More changes:

- Releases: https://github.com/WeihanLi/WeihanLi.EntityFramework/releases
- PRs: https://github.com/WeihanLi/WeihanLi.EntityFramework/pulls?q=is%3Apr+is%3Aclosed+is%3Amerged+base%3Amaster

## WeihanLi.EntityFramework

### [WeihanLi.EntityFramework 1.8.0](https://www.nuget.org/packages/WeihanLi.EntityFramework/1.8.0)
Expand Down
4 changes: 2 additions & 2 deletions samples/WeihanLi.EntityFramework.Sample/AutoAuditContext1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace WeihanLi.EntityFramework.Sample;
public class AutoAuditContext1(DbContextOptions dbContextOptions, IServiceProvider serviceProvider)
: AuditDbContext(dbContextOptions, serviceProvider)
{
public DbSet<TestJobEntity> Jobs { get; set; }
public DbSet<TestJobEntity> Jobs { get; set; } = null!;
}


public class AutoAuditContext2(DbContextOptions<AutoAuditContext2> options) : DbContext(options)
{
public DbSet<TestJobEntity> Jobs { get; set; }
public DbSet<TestJobEntity> Jobs { get; set; } = null!;
}

public class TestJobEntity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.DependencyInjection;
using WeihanLi.Extensions;

namespace WeihanLi.EntityFramework.Sample;

public static class DbContextInterceptorSamples
{
public static async Task RunAsync()
{
await InterceptorTest2();
}

private static async Task InterceptorTest1()
{
var services = new ServiceCollection();
services.AddScoped<SavingInterceptor>();
services.AddDbContext<FileTestDbContext>((provider, options) =>
{
options.AddInterceptors(provider.GetRequiredService<SavingInterceptor>());
options.UseInMemoryDatabase("test");
});
await using var provider = services.BuildServiceProvider();
using var scope = provider.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<FileTestDbContext>();
await dbContext.Database.EnsureCreatedAsync();
dbContext.Entities.Add(new TestEntity { Id = 1, Name = "1" });
await dbContext.SaveChangesAsync();
}

private static async Task InterceptorTest2()
{
var services = new ServiceCollection();
services.AddDbContext<FileTestDbContext>(options =>
{
options.UseInMemoryDatabase("test");
});
services.AddDbContextInterceptor<FileTestDbContext, SavingInterceptor>();
await using var provider = services.BuildServiceProvider();
using var scope = provider.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<FileTestDbContext>();
await dbContext.Database.EnsureCreatedAsync();
dbContext.Entities.Add(new TestEntity { Id = 2, Name = "1" });
await dbContext.SaveChangesAsync();
}
}

file sealed class FileTestDbContext(DbContextOptions<FileTestDbContext> options) : DbContext(options)
{
public DbSet<TestEntity> Entities { get; set; }
}

file sealed class TestEntity
{
public int Id { get; set; }
public string Name { get; set; }

Check warning on line 57 in samples/WeihanLi.EntityFramework.Sample/DbContextInterceptorSamples.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 57 in samples/WeihanLi.EntityFramework.Sample/DbContextInterceptorSamples.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 57 in samples/WeihanLi.EntityFramework.Sample/DbContextInterceptorSamples.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 57 in samples/WeihanLi.EntityFramework.Sample/DbContextInterceptorSamples.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}

file sealed class SavingInterceptor : SaveChangesInterceptor
{
public override ValueTask<InterceptionResult<int>> SavingChangesAsync(DbContextEventData eventData, InterceptionResult<int> result,
CancellationToken cancellationToken = default)
{
Console.WriteLine("SavingChangesAsync");
return base.SavingChangesAsync(eventData, result, cancellationToken);
}

public override ValueTask<int> SavedChangesAsync(SaveChangesCompletedEventData eventData, int result,
CancellationToken cancellationToken = default)
{
Console.WriteLine("SavedChangesAsync");
return base.SavedChangesAsync(eventData, result, cancellationToken);
}
}
Loading

0 comments on commit fac7df1

Please sign in to comment.