EntityFrameworkCore.Parallel
3.0.5
See the version list below for details.
dotnet add package EntityFrameworkCore.Parallel --version 3.0.5
NuGet\Install-Package EntityFrameworkCore.Parallel -Version 3.0.5
<PackageReference Include="EntityFrameworkCore.Parallel" Version="3.0.5" />
paket add EntityFrameworkCore.Parallel --version 3.0.5
#r "nuget: EntityFrameworkCore.Parallel, 3.0.5"
// Install EntityFrameworkCore.Parallel as a Cake Addin #addin nuget:?package=EntityFrameworkCore.Parallel&version=3.0.5 // Install EntityFrameworkCore.Parallel as a Cake Tool #tool nuget:?package=EntityFrameworkCore.Parallel&version=3.0.5
EntityFrameworkCore.Parallel
This extension to Entity Framework Core adds a Set<TContext, TEntity>()
method to IDbContextFactory<TContext>
.
This allows you to easily execute multiple queries in parallel without the need to write complex code, or a lot of using
blocks or statements.
You can stick to all your known methods from IQueryable<TEntity>
.
As the context is disposed after your query is executed, all results will obviously not be tracked and disconnected from any DbContext
.
How to use
In your Startup
class, add a DbContextfactory
. If you want a pooled one, or not is up to you.
services.AddPooledDbContextFactory<OrderContext>(options => options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=OrderTest"));
In your business class, inject an IDbContextFactory<TContext>
and use it like this
var ordersFromDb = await _factory.Parallel().Set<Order>().Where(o => o.Id > 3).ToListAsync();
Or like this
var ordersFromDb = await _factory.Set<MyContext, Order>().Where(o => o.Id > 3).ToListAsync();
Migration from Entity Framework Core 5 to 6
In Entity Framework Core 6, IDbContextFactory<TContext>
is no longer covariant (TContext
is not marked with the out
keyword).
Because of that, the following code does no longer work.
var ordersFromDb = await _factory.Set<Order>().Where(o => o.Id > 3).ToListAsync();
See the How to use section for two possibilities that you can use instead. If you want some background information, have a look at https://github.com/dotnet/efcore/issues/26630
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.EntityFrameworkCore (>= 7.0.7)
- System.Interactive.Async (>= 6.0.1)
- System.Linq.Async (>= 6.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EntityFrameworkCore.Parallel:
Package | Downloads |
---|---|
RESTworld.Business
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.1.1 | 483 | 10/11/2024 |
4.1.0 | 832 | 9/20/2024 |
4.0.5 | 630 | 7/10/2024 |
4.0.4 | 245 | 6/4/2024 |
4.0.3 | 115 | 5/24/2024 |
4.0.2 | 270 | 4/19/2024 |
4.0.1 | 1,873 | 1/9/2024 |
4.0.0 | 659 | 11/14/2023 |
3.0.9 | 425 | 10/23/2023 |
3.0.8 | 427 | 9/5/2023 |
3.0.7 | 463 | 7/17/2023 |
3.0.6 | 391 | 6/28/2023 |
3.0.5 | 991 | 6/14/2023 |
3.0.4 | 801 | 4/18/2023 |
3.0.3 | 753 | 2/22/2023 |
3.0.2 | 391 | 2/9/2023 |
3.0.1 | 885 | 12/21/2022 |
3.0.0 | 1,159 | 11/9/2022 |
2.2.0 | 3,343 | 10/20/2022 |
2.1.0 | 2,192 | 6/28/2022 |
2.0.3 | 2,769 | 5/13/2022 |
2.0.2 | 3,694 | 3/9/2022 |
2.0.1 | 2,284 | 2/22/2022 |
2.0.0 | 3,116 | 12/1/2021 |
1.0.2 | 1,064 | 11/4/2021 |
1.0.1 | 2,910 | 9/7/2021 |
1.0.0 | 2,348 | 11/24/2020 |