Skip to content

Merged PRs, cleanups, fixes #153

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

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a059d0f
Support Transaction Scope
SPEMoorthy Feb 15, 2018
550eb38
Changed using System.Data;
SPEMoorthy Feb 16, 2018
72ecc09
Merge branch 'TxnScope#60' into Dev
SPEMoorthy Feb 16, 2018
98368ae
Merge pull request #1 from Arch/master
SPEMoorthy Feb 23, 2018
daadfe7
Resolved Conflict After Trackgrap API Commited.
SPEMoorthy Feb 23, 2018
e4ef99d
Corrected Alignment
SPEMoorthy Feb 23, 2018
b50fb7f
Merge branch 'TxnScope#60' into master
SPEMoorthy Feb 23, 2018
e8bb14b
Removed SaveChangesAsync Dublicate method.
SPEMoorthy Mar 1, 2018
6a6329c
Update IUnitOfWork.cs
SPEMoorthy Mar 1, 2018
28df442
Raw Sql Returns DataTable
SPEMoorthy Mar 12, 2018
7334bef
SQL Dataset Corrected
SPEMoorthy Aug 2, 2018
b6943d3
Get List with predicate
SPEMoorthy Aug 16, 2018
e1558bd
Previous Next Functionality Partially Implemented
SPEMoorthy Sep 17, 2018
654bc6d
First Next Previous Last Functionality
SPEMoorthy Sep 27, 2018
f6f5a29
Pre Next Bug Fixed
SPEMoorthy Oct 4, 2018
d54c30f
Prev Next Bug Fixed
SPEMoorthy Oct 4, 2018
8100a95
Dot Net Core 2.2 Updated
SPEMoorthy Oct 22, 2018
67da6f8
Update Microsoft.EntityFrameworkCore.UnitOfWork.csproj
RamyaYogi Dec 19, 2018
d22d18b
Update Microsoft.EntityFrameworkCore.UnitOfWork.csproj
SPEMoorthy Dec 25, 2018
5388de4
Modified to New Version
SPEMoorthy Mar 13, 2019
0695381
Update README.md
SPEMoorthy Mar 19, 2019
5bd4612
PK Int to Long
SPEMoorthy Aug 6, 2019
1b0a7bf
Re Referenced Autohistory
SPEMoorthy Nov 6, 2019
620ae2e
Update Microsoft.EntityFrameworkCore.UnitOfWork.csproj
SPEMoorthy Feb 29, 2020
213f670
Increment Decrement Changes
ManiPsP Jan 19, 2021
807054a
Update Repository.cs
SPEMoorthy Jan 20, 2021
c77ddd8
Merge branch 'Arch-master' into dev
SPEMoorthy Feb 16, 2021
97904ac
UniOfWork
SPEMoorthy Feb 17, 2021
4c3f678
Merge branch 'Arch-master' into Dev
SPEMoorthy Feb 17, 2021
8c04a3d
.Net 5.0
SPEMoorthy Mar 3, 2021
8eca165
Packeges Upgraded
SPEMoorthy Mar 5, 2021
a40b861
Merge pull request #6 from SPEMoorthy/Dev
SPEMoorthy Jun 24, 2021
2824636
Merged Code Change From Retail Modification
ManiPsP Jun 25, 2021
56909c3
Datatable issue
SPEMoorthy Aug 3, 2021
aff6a59
DS
SPEMoorthy Aug 4, 2021
0654d02
Merge branch 'Arch:master' into Dev
SPEMoorthy Aug 4, 2021
acacf5f
Merge pull request #4 from Arch/master
SPEMoorthy Aug 4, 2021
1abea6a
Merge pull request #7 from SITSLN/Dev
SPEMoorthy Aug 4, 2021
8e9521e
.Net 5.0
SPEMoorthy Aug 5, 2021
e1ed3db
Update UnitOfWork.csproj
SPEMoorthy Aug 5, 2021
f6739d0
Update dotnet 6 and nugets.
pluskal Jan 27, 2022
aebc5fe
Use async overloads where possible. Use await using...
pluskal Jan 27, 2022
5dbe683
Fix rootNamespaces and remove duplicit IRepositoryFactory.cs
pluskal Jan 27, 2022
1ac77b4
Cleanup tests - Make it compliant with C#10 coding standards.
pluskal Jan 27, 2022
1c5b65d
Improve Arch.EntityFrameworkCore.UnitOfWork.* code readability. Unify…
pluskal Jan 27, 2022
83700a9
Clean host app
pluskal Jan 27, 2022
8521dfd
Remove old commented out code.
pluskal Jan 27, 2022
191791d
Continue Improve Arch.EntityFrameworkCore.UnitOfWork.* code readabili…
pluskal Jan 27, 2022
506418e
Fix Repository API. Expression<Func<TEntity, T>> selector cannot be o…
pluskal Jan 27, 2022
6915d2f
Make Repository implement IAsyncDisposable
pluskal Jan 27, 2022
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
258 changes: 129 additions & 129 deletions samples/UnitOfWork.Host/Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Arch.EntityFrameworkCore.UnitOfWork.Host.Controllers
public class ValuesController : Controller
{
private readonly IUnitOfWork _unitOfWork;
private ILogger<ValuesController> _logger;
private readonly ILogger<ValuesController> _logger;

// 1. IRepositoryFactory used for readonly scenario;
// 2. IUnitOfWork used for read/write scenario;
Expand All @@ -27,135 +27,137 @@ public ValuesController(IUnitOfWork unitOfWork, ILogger<ValuesController> logger
var repo = _unitOfWork.GetRepository<Blog>(hasCustomRepository: true);
if (repo.Count() == 0)
{
repo.Insert(new Blog
{
Id = 1,
Url = "/a/" + 1,
Title = $"a{1}",
Posts = new List<Post>{
new Post
{
Id = 1,
Title = "A",
Content = "A's content",
Comments = new List<Comment>
{
new Comment
{
Id = 1,
Title = "A",
Content = "A's content",
},
new Comment
{
Id = 2,
Title = "b",
Content = "b's content",
},
new Comment
{
Id = 3,
Title = "c",
Content = "c's content",
}
},
},
new Post
{
Id = 2,
Title = "B",
Content = "B's content",
Comments = new List<Comment>
{
new Comment
{
Id = 4,
Title = "A",
Content = "A's content",
},
new Comment
{
Id = 5,
Title = "b",
Content = "b's content",
},
new Comment
{
Id = 6,
Title = "c",
Content = "c's content",
}
},
},
new Post
{
Id = 3,
Title = "C",
Content = "C's content",
Comments = new List<Comment>
{
new Comment
{
Id = 7,
Title = "A",
Content = "A's content",
},
new Comment
{
Id = 8,
Title = "b",
Content = "b's content",
},
new Comment
{
Id = 9,
Title = "c",
Content = "c's content",
}
},
},
new Post
{
Id = 4,
Title = "D",
Content = "D's content",
Comments = new List<Comment>
{
new Comment
{
Id = 10,
Title = "A",
Content = "A's content",
},
new Comment
{
Id = 11,
Title = "b",
Content = "b's content",
},
new Comment
{
Id = 12,
Title = "c",
Content = "c's content",
}
},
}
},
});
SeedInitialEntities(repo);
_unitOfWork.SaveChanges();
}
}

private static void SeedInitialEntities(IRepository<Blog> repo)
=> repo.Insert(new Blog
{
Id = 1,
Url = "/a/" + 1,
Title = $"a{1}",
Posts = new List<Post>{
new Post
{
Id = 1,
Title = "A",
Content = "A's content",
Comments = new List<Comment>
{
new Comment
{
Id = 1,
Title = "A",
Content = "A's content",
},
new Comment
{
Id = 2,
Title = "b",
Content = "b's content",
},
new Comment
{
Id = 3,
Title = "c",
Content = "c's content",
}
},
},
new Post
{
Id = 2,
Title = "B",
Content = "B's content",
Comments = new List<Comment>
{
new Comment
{
Id = 4,
Title = "A",
Content = "A's content",
},
new Comment
{
Id = 5,
Title = "b",
Content = "b's content",
},
new Comment
{
Id = 6,
Title = "c",
Content = "c's content",
}
},
},
new Post
{
Id = 3,
Title = "C",
Content = "C's content",
Comments = new List<Comment>
{
new Comment
{
Id = 7,
Title = "A",
Content = "A's content",
},
new Comment
{
Id = 8,
Title = "b",
Content = "b's content",
},
new Comment
{
Id = 9,
Title = "c",
Content = "c's content",
}
},
},
new Post
{
Id = 4,
Title = "D",
Content = "D's content",
Comments = new List<Comment>
{
new Comment
{
Id = 10,
Title = "A",
Content = "A's content",
},
new Comment
{
Id = 11,
Title = "b",
Content = "b's content",
},
new Comment
{
Id = 12,
Title = "c",
Content = "c's content",
}
},
}
},
});

// GET api/values
[HttpGet]
public async Task<IList<Blog>> Get()
{
return await _unitOfWork.GetRepository<Blog>().GetAllAsync(include: source => source.Include(blog => blog.Posts).ThenInclude(post => post.Comments));
}
public async Task<IList<Blog>> Get()
=> await _unitOfWork.GetRepository<Blog>()
.GetAllAsync(include: source => source.Include(blog => blog.Posts).ThenInclude(post => post.Comments));

// GET api/values/Page/5/10
[HttpGet("Page/{pageIndex}/{pageSize}")]
[HttpGet("Page/{pageIndex:int}/{pageSize:int}")]
public async Task<IPagedList<Blog>> Get(int pageIndex, int pageSize)
{
// projection
Expand All @@ -170,11 +172,11 @@ public async Task<IPagedList<Blog>> Get(string term)
{
_logger.LogInformation("demo about first or default with include");

var item = _unitOfWork.GetRepository<Blog>().GetFirstOrDefault(predicate: x => x.Title.Contains(term), include: source => source.Include(blog => blog.Posts).ThenInclude(post => post.Comments));
var item = await _unitOfWork.GetRepository<Blog>().GetFirstOrDefaultAsync(predicate: x => x.Title.Contains(term), include: source => source.Include(blog => blog.Posts).ThenInclude(post => post.Comments));

_logger.LogInformation("demo about first or default without include");

item = _unitOfWork.GetRepository<Blog>().GetFirstOrDefault(predicate: x => x.Title.Contains(term), orderBy: source => source.OrderByDescending(b => b.Id));
item = await _unitOfWork.GetRepository<Blog>().GetFirstOrDefaultAsync(predicate: x => x.Title.Contains(term), orderBy: source => source.OrderByDescending(b => b.Id));

_logger.LogInformation("demo about first or default with projection");

Expand All @@ -184,11 +186,9 @@ public async Task<IPagedList<Blog>> Get(string term)
}

// GET api/values/4
[HttpGet("{id}")]
public async Task<Blog> Get(int id)
{
return await _unitOfWork.GetRepository<Blog>().FindAsync(id);
}
[HttpGet("{id:int}")]
public async Task<Blog> Get(int id)
=> await _unitOfWork.GetRepository<Blog>().FindAsync(id);

// POST api/values
[HttpPost]
Expand Down
5 changes: 1 addition & 4 deletions samples/UnitOfWork.Host/Models/BlogggingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions samples/UnitOfWork.Host/Models/CustomBlogRepository.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
namespace Arch.EntityFrameworkCore.UnitOfWork.Host.Models
{
public class CustomBlogRepository : Repository<Blog>, IRepository<Blog>
public class CustomBlogRepository : Repository<Blog>
{
public CustomBlogRepository(BloggingContext dbContext) : base(dbContext)
{

}
}
}
4 changes: 2 additions & 2 deletions samples/UnitOfWork.Host/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public void ConfigureServices(IServiceCollection services)
{
// use in memory for testing.
services
.AddDbContext<BloggingContext>(opt => opt.UseMySql("Server=localhost;database=uow;uid=root;pwd=root1234;"))
//.AddDbContext<BloggingContext>(opt => opt.UseInMemoryDatabase("UnitOfWork"))
//.AddDbContext<BloggingContext>(opt => opt.UseMySql("Server=localhost;database=uow;uid=root;pwd=root1234;"))
.AddDbContext<BloggingContext>(opt => opt.UseInMemoryDatabase("UnitOfWork"))
.AddUnitOfWork<BloggingContext>()
.AddCustomRepository<Blog, CustomBlogRepository>();

Expand Down
23 changes: 13 additions & 10 deletions samples/UnitOfWork.Host/UnitOfWork.Host.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Arch.EntityFrameworkCore.UnitOfWork.Host</RootNamespace>
<PreserveCompilationContext>true</PreserveCompilationContext>
<OutputType>Exe</OutputType>
</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.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" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.5" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\UnitOfWork\UnitOfWork.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Arch.EntityFrameworkCore.UnitOfWork.Collections
/// <summary>
/// Provides some extension methods for <see cref="IEnumerable{T}"/> to provide paging capability.
/// </summary>
public static class IEnumerablePagedListExtensions
public static class EnumerablePagedListExtensions
{
/// <summary>
/// Converts the specified source to <see cref="IPagedList{T}"/> by the specified <paramref name="pageIndex"/> and <paramref name="pageSize"/>.
Expand Down
Loading