Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
51 changes: 45 additions & 6 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,65 @@ name: .NET

on:
push:
branches: [ "master" ]
branches: [ "main" ]
pull_request:
branches: [ "master" ]
branches: [ "main" ]

permissions:
contents: read

jobs:
build:
runs-on: windows-latest
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v4

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
test-sqlserver:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Restore dependencies
run: dotnet restore

- name: Test SqlServer
run: dotnet test "N.EntityFrameworkCore.Extensions.Test/N.EntityFramework.Extensions.SqlServer.Test/N.EntityFramework.Extensions.SqlServer.Test.csproj" --configuration Release --settings N.EntityFramework.Extensions.SqlServer.runsettings --verbosity normal

test-mysql:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Restore dependencies
run: dotnet restore

- name: Test MySQL
run: dotnet test "N.EntityFrameworkCore.Extensions.Test/N.EntityFramework.Extensions.MySql.Test/N.EntityFramework.Extensions.MySql.Test.csproj" --configuration Release --settings N.EntityFramework.Extensions.MySql.runsettings --verbosity normal

test-postgresql:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Restore dependencies
run: dotnet restore

- name: Test PostgreSQL
run: dotnet test "N.EntityFrameworkCore.Extensions.Test/N.EntityFramework.Extensions.PostgreSql.Test/N.EntityFramework.Extensions.PostgreSql.Test.csproj" --configuration Release --settings N.EntityFramework.Extensions.PostgreSql.runsettings --verbosity normal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<MaxCpuCount>1</MaxCpuCount>
<MaxCpuCount>4</MaxCpuCount>
</RunConfiguration>
<LoggerRunSettings>
<Loggers>
Expand Down
6 changes: 6 additions & 0 deletions N.EntityFramework.Extensions.MySql/Common/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace N.EntityFrameworkCore.Extensions.Common;

public static class Constants
{
public static readonly string InternalId_ColumnName = "_be_xx_id";
}
9 changes: 9 additions & 0 deletions N.EntityFramework.Extensions.MySql/Data/BulkDeleteOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;
using System.Linq.Expressions;

namespace N.EntityFrameworkCore.Extensions;

public class BulkDeleteOptions<T> : BulkOptions
{
public Expression<Func<T, T, bool>> DeleteOnCondition { get; set; }
}
11 changes: 11 additions & 0 deletions N.EntityFramework.Extensions.MySql/Data/BulkFetchOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Linq.Expressions;

namespace N.EntityFrameworkCore.Extensions;

public class BulkFetchOptions<T> : BulkOptions
{
public Expression<Func<T, object>> IgnoreColumns { get; set; }
public Expression<Func<T, object>> InputColumns { get; set; }
public Expression<Func<T, T, bool>> JoinOnCondition { get; set; }
}
27 changes: 27 additions & 0 deletions N.EntityFramework.Extensions.MySql/Data/BulkInsertOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Linq;
using System.Linq.Expressions;

namespace N.EntityFrameworkCore.Extensions;

public class BulkInsertOptions<T> : BulkOptions
{
public bool AutoMapOutput { get; set; }
public Expression<Func<T, object>> IgnoreColumns { get; set; }
public Expression<Func<T, object>> InputColumns { get; set; }
public bool InsertIfNotExists { get; set; }
public Expression<Func<T, T, bool>> InsertOnCondition { get; set; }
public bool KeepIdentity { get; set; }

public string[] GetInputColumns() =>
InputColumns?.Body.Type.GetProperties().Select(o => o.Name).ToArray();

public BulkInsertOptions()
{
AutoMapOutput = true;
}
internal BulkInsertOptions(BulkOptions options)
{
EntityType = options.EntityType;
}
}
9 changes: 9 additions & 0 deletions N.EntityFramework.Extensions.MySql/Data/BulkInsertResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace N.EntityFrameworkCore.Extensions;

internal sealed class BulkInsertResult<T>
{
internal int RowsAffected { get; set; }
internal Dictionary<long, T> EntityMap { get; set; }
}
24 changes: 24 additions & 0 deletions N.EntityFramework.Extensions.MySql/Data/BulkMergeOption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace N.EntityFrameworkCore.Extensions;

public class BulkMergeOptions<T> : BulkOptions
{
public Expression<Func<T, T, bool>> MergeOnCondition { get; set; }
public Expression<Func<T, object>> IgnoreColumnsOnInsert { get; set; }
public Expression<Func<T, object>> IgnoreColumnsOnUpdate { get; set; }
public bool AutoMapOutput { get; set; }
internal bool DeleteIfNotMatched { get; set; }

public BulkMergeOptions()
{
AutoMapOutput = true;
}
public List<string> GetIgnoreColumnsOnInsert() =>
IgnoreColumnsOnInsert?.Body.Type.GetProperties().Select(o => o.Name).ToList() ?? [];
public List<string> GetIgnoreColumnsOnUpdate() =>
IgnoreColumnsOnUpdate?.Body.Type.GetProperties().Select(o => o.Name).ToList() ?? [];
}
11 changes: 11 additions & 0 deletions N.EntityFramework.Extensions.MySql/Data/BulkMergeOutputRow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace N.EntityFrameworkCore.Extensions;

public class BulkMergeOutputRow<T>
{
public string Action { get; set; }

public BulkMergeOutputRow(string action)
{
Action = action;
}
}
12 changes: 12 additions & 0 deletions N.EntityFramework.Extensions.MySql/Data/BulkMergeResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;

namespace N.EntityFrameworkCore.Extensions;

public class BulkMergeResult<T>
{
public IEnumerable<BulkMergeOutputRow<T>> Output { get; set; }
public int RowsAffected { get; set; }
public int RowsDeleted { get; internal set; }
public int RowsInserted { get; internal set; }
public int RowsUpdated { get; internal set; }
}
Loading
Loading