Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Nuget Packages #141

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .cr/personal/FavoritesList/List.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Root Type="DevExpress.CodeRush.Foundation.CodePlaces.Options.FavoritesListContainer">
<Options Language="Neutral">
<Groups />
</Options>
</Root>
1 change: 1 addition & 0 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ jobs:
run: dotnet restore
- name: Build
run: dotnet build --configuration Release

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

[![time tracker](https://wakatime.com/badge/github/AIKICo/UnitOfWork.svg)](https://wakatime.com/badge/github/AIKICo/UnitOfWork)
# UnitOfWork
A plugin for Microsoft.EntityFrameworkCore to support repository, unit of work patterns, and multiple database with distributed transaction supported.

Expand Down
14 changes: 0 additions & 14 deletions UnitOfWork.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9661
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitOfWork", "src\UnitOfWork\UnitOfWork.csproj", "{FD8010C2-982B-470E-A9A5-C0DFA2D14809}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitOfWork.Tests", "test\UnitOfWork.Tests\UnitOfWork.Tests.csproj", "{FDAA4086-21E8-4939-8539-0A1723EC4922}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitOfWork.Host", "samples\UnitOfWork.Host\UnitOfWork.Host.csproj", "{207188FE-2344-4DC1-8656-E02CEF741422}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -30,22 +26,12 @@ Global
{FD8010C2-982B-470E-A9A5-C0DFA2D14809}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD8010C2-982B-470E-A9A5-C0DFA2D14809}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD8010C2-982B-470E-A9A5-C0DFA2D14809}.Release|Any CPU.Build.0 = Release|Any CPU
{FDAA4086-21E8-4939-8539-0A1723EC4922}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDAA4086-21E8-4939-8539-0A1723EC4922}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDAA4086-21E8-4939-8539-0A1723EC4922}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDAA4086-21E8-4939-8539-0A1723EC4922}.Release|Any CPU.Build.0 = Release|Any CPU
{207188FE-2344-4DC1-8656-E02CEF741422}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{207188FE-2344-4DC1-8656-E02CEF741422}.Debug|Any CPU.Build.0 = Debug|Any CPU
{207188FE-2344-4DC1-8656-E02CEF741422}.Release|Any CPU.ActiveCfg = Release|Any CPU
{207188FE-2344-4DC1-8656-E02CEF741422}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FD8010C2-982B-470E-A9A5-C0DFA2D14809} = {14F86AF9-D2C9-468D-8C71-9BC4785F68A0}
{FDAA4086-21E8-4939-8539-0A1723EC4922} = {D3C7F3F5-4AB2-4868-8D2C-516DFCFDC349}
{207188FE-2344-4DC1-8656-E02CEF741422} = {9661083F-4BCD-42D4-9EF8-1187DD9EDA60}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A7B21B30-8D65-449B-B192-64726743EFC3}
Expand Down
1 change: 1 addition & 0 deletions samples/UnitOfWork.Host/Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Arch.EntityFrameworkCore.UnitOfWork.Host.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using UnitOfWork.Host.Models;

namespace Arch.EntityFrameworkCore.UnitOfWork.Host.Controllers
{
Expand Down
7 changes: 2 additions & 5 deletions samples/UnitOfWork.Host/Models/BlogggingContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace Arch.EntityFrameworkCore.UnitOfWork.Host.Models
namespace UnitOfWork.Host.Models
{
public class BloggingContext : DbContext
{
Expand All @@ -12,10 +12,7 @@ public BloggingContext(DbContextOptions<BloggingContext> options)
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.EnableAutoHistory(null);
}
protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.EnableAutoHistory(null);
}

public class Blog
Expand Down
4 changes: 3 additions & 1 deletion samples/UnitOfWork.Host/Models/CustomBlogRepository.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Arch.EntityFrameworkCore.UnitOfWork.Host.Models
using UnitOfWork.Host.Models;

namespace Arch.EntityFrameworkCore.UnitOfWork.Host.Models
{
public class CustomBlogRepository : Repository<Blog>, IRepository<Blog>
{
Expand Down
1 change: 1 addition & 0 deletions samples/UnitOfWork.Host/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;
using UnitOfWork.Host.Models;

namespace Arch.EntityFrameworkCore.UnitOfWork.Host
{
Expand Down
2 changes: 2 additions & 0 deletions samples/UnitOfWork.Host/UnitOfWork.Host.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.5" />
Expand Down
144 changes: 89 additions & 55 deletions src/UnitOfWork/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,40 @@ IPagedList<TEntity> GetPagedList(Expression<Func<TEntity, bool>> predicate = nul
bool disableTracking = true,
bool ignoreQueryFilters = false);

/// <summary>
/// Gets all entities. This method is not recommended
/// </summary>
/// <param name="selector">The selector for projection.</param>
/// <param name="predicate">A function to test each element for a condition.</param>
/// <param name="orderBy">A function to order elements.</param>
/// <param name="include">A function to include navigation properties</param>
/// <param name="disableTracking"><c>true</c> to disable changing tracking; otherwise, <c>false</c>. Default to <c>true</c>.</param>
/// <param name="ignoreQueryFilters">Ignore query filters</param>
/// <returns>An <see cref="IPagedList{TEntity}"/> that contains elements that satisfy the condition specified by <paramref name="predicate"/>.</returns>
/// <remarks>Ex: This method defaults to a read-only, no-tracking query.</remarks>
IQueryable<TResult> GetAll<TResult>(Expression<Func<TEntity, TResult>> selector,
Expression<Func<TEntity, bool>> predicate = null,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null, bool disableTracking = true, bool ignoreQueryFilters = false);

/// <summary>
/// Gets all entities. This method is not recommended
/// </summary>
/// <param name="selector">The selector for projection.</param>
/// <param name="predicate">A function to test each element for a condition.</param>
/// <param name="orderBy">A function to order elements.</param>
/// <param name="include">A function to include navigation properties</param>
/// <param name="disableTracking"><c>true</c> to disable changing tracking; otherwise, <c>false</c>. Default to <c>true</c>.</param>
/// <param name="ignoreQueryFilters">Ignore query filters</param>
/// <returns>An <see cref="IPagedList{TEntity}"/> that contains elements that satisfy the condition specified by <paramref name="predicate"/>.</returns>
/// <remarks>Ex: This method defaults to a read-only, no-tracking query.</remarks>
Task<IList<TResult>> GetAllAsync<TResult>(Expression<Func<TEntity, TResult>> selector,
Expression<Func<TEntity, bool>> predicate = null,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null,
bool disableTracking = true,
bool ignoreQueryFilters = false);

/// <summary>
/// Gets the <see cref="IPagedList{TEntity}"/> based on a predicate, orderby delegate and page information. This method default no-tracking query.
/// </summary>
Expand Down Expand Up @@ -244,24 +278,6 @@ IQueryable<TEntity> GetAll(Expression<Func<TEntity, bool>> predicate = null,
bool disableTracking = true,
bool ignoreQueryFilters = false);

/// <summary>
/// Gets all entities. This method is not recommended
/// </summary>
/// <param name="selector">The selector for projection.</param>
/// <param name="predicate">A function to test each element for a condition.</param>
/// <param name="orderBy">A function to order elements.</param>
/// <param name="include">A function to include navigation properties</param>
/// <param name="disableTracking"><c>true</c> to disable changing tracking; otherwise, <c>false</c>. Default to <c>true</c>.</param>
/// <param name="ignoreQueryFilters">Ignore query filters</param>
/// <returns>An <see cref="IPagedList{TEntity}"/> that contains elements that satisfy the condition specified by <paramref name="predicate"/>.</returns>
/// <remarks>Ex: This method defaults to a read-only, no-tracking query.</remarks>
IQueryable<TResult> GetAll<TResult>(Expression<Func<TEntity,TResult>> selector,
Expression<Func<TEntity, bool>> predicate = null,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null,
bool disableTracking = true,
bool ignoreQueryFilters = false);

/// <summary>
/// Gets all entities. This method is not recommended
/// </summary>
Expand All @@ -284,128 +300,124 @@ Task<IList<TEntity>> GetAllAsync(Expression<Func<TEntity, bool>> predicate = nul
bool disableTracking = true,
bool ignoreQueryFilters = false);

/// <summary>
/// Gets all entities. This method is not recommended
/// </summary>
/// <param name="selector">The selector for projection.</param>
/// <param name="predicate">A function to test each element for a condition.</param>
/// <param name="orderBy">A function to order elements.</param>
/// <param name="include">A function to include navigation properties</param>
/// <param name="disableTracking"><c>true</c> to disable changing tracking; otherwise, <c>false</c>. Default to <c>true</c>.</param>
/// <param name="ignoreQueryFilters">Ignore query filters</param>
/// <returns>An <see cref="IPagedList{TEntity}"/> that contains elements that satisfy the condition specified by <paramref name="predicate"/>.</returns>
/// <remarks>Ex: This method defaults to a read-only, no-tracking query.</remarks>
Task<IList<TResult>> GetAllAsync<TResult>(Expression<Func<TEntity, TResult>> selector,
Expression<Func<TEntity, bool>> predicate = null,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null,
bool disableTracking = true,
bool ignoreQueryFilters = false);

/// <summary>
/// Gets the count based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns></returns>
int Count(Expression<Func<TEntity, bool>> predicate = null);
int Count(Expression<Func<TEntity, bool>> predicate = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets async the count based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns></returns>
Task<int> CountAsync(Expression<Func<TEntity, bool>> predicate = null);
Task<int> CountAsync(Expression<Func<TEntity, bool>> predicate = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets the long count based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns></returns>
long LongCount(Expression<Func<TEntity, bool>> predicate = null);
long LongCount(Expression<Func<TEntity, bool>> predicate = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets async the long count based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns></returns>
Task<long> LongCountAsync(Expression<Func<TEntity, bool>> predicate = null);
Task<long> LongCountAsync(Expression<Func<TEntity, bool>> predicate = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets the max based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// /// <param name="selector"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns>decimal</returns>
T Max<T>(Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, T>> selector = null);
T Max<T>(Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, T>> selector = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets the async max based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// /// <param name="selector"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns>decimal</returns>
Task<T> MaxAsync<T>(Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, T>> selector = null);
Task<T> MaxAsync<T>(Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, T>> selector = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets the min based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// <param name="selector"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns>decimal</returns>
T Min<T>(Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, T>> selector = null);
T Min<T>(Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, T>> selector = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets the async min based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// <param name="selector"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns>decimal</returns>
Task<T> MinAsync<T>(Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, T>> selector = null);
Task<T> MinAsync<T>(Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, T>> selector = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets the average based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// /// <param name="selector"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns>decimal</returns>
decimal Average (Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, decimal>> selector = null);
decimal Average (Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, decimal>> selector = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets the async average based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// /// <param name="selector"></param>
/// <returns>decimal</returns>
Task<decimal> AverageAsync(Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, decimal>> selector = null);
/// Gets the async average based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// /// <param name="selector"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns>decimal</returns>
Task<decimal> AverageAsync(Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, decimal>> selector = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets the sum based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// /// <param name="selector"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns>decimal</returns>
decimal Sum (Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, decimal>> selector = null);
decimal Sum (Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, decimal>> selector = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets the async sum based on a predicate.
/// </summary>
/// <param name="predicate"></param>
/// /// <param name="selector"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns>decimal</returns>
Task<decimal> SumAsync (Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, decimal>> selector = null);
Task<decimal> SumAsync (Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, decimal>> selector = null, bool ignoreQueryFilters = false);

/// <summary>
/// Gets the Exists record based on a predicate.
/// </summary>
/// <param name="selector"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns></returns>
bool Exists(Expression<Func<TEntity, bool>> selector = null);
bool Exists(Expression<Func<TEntity, bool>> selector = null, bool ignoreQueryFilters = false);
/// <summary>
/// Gets the Async Exists record based on a predicate.
/// </summary>
/// <param name="selector"></param>
/// <param name="ignoreQueryFilters"></param>
/// <returns></returns>
Task<bool> ExistsAsync(Expression<Func<TEntity, bool>> selector = null);
Task<bool> ExistsAsync(Expression<Func<TEntity, bool>> selector = null, bool ignoreQueryFilters = false);

/// <summary>
/// Inserts a new entity synchronously.
Expand Down Expand Up @@ -490,6 +502,28 @@ Task<IList<TResult>> GetAllAsync<TResult>(Expression<Func<TEntity, TResult>> sel
/// <param name="entities">The entities.</param>
void Delete(IEnumerable<TEntity> entities);

/// <summary>
/// Bulk Delete the specified entity.
/// </summary>
void BulkDelete();

/// <summary>
/// ASync Bulk Delete the specified entity.
/// </summary>
Task BulkDeleteAsync();

/// <summary>
/// Bulk Update the specified entity.
/// <param name="setPropertyCalls">the entity property</param>
/// </summary>
void BulkUpdate(Expression<Func<SetPropertyCalls<TEntity>, SetPropertyCalls<TEntity>>> setPropertyCalls);

/// <summary>
/// Async Bulk Update the specified entity.
/// <param name="setPropertyCalls">the entity property</param>
/// </summary>
Task BulkUpdateAsync(Expression<Func<SetPropertyCalls<TEntity>, SetPropertyCalls<TEntity>>> setPropertyCalls);

/// <summary>
/// Change entity state for patch method on web api.
/// </summary>
Expand Down
Loading