LinqAsync.EFCore
1.1.0
dotnet add package LinqAsync.EFCore --version 1.1.0
NuGet\Install-Package LinqAsync.EFCore -Version 1.1.0
<PackageReference Include="LinqAsync.EFCore" Version="1.1.0" />
paket add LinqAsync.EFCore --version 1.1.0
#r "nuget: LinqAsync.EFCore, 1.1.0"
// Install LinqAsync.EFCore as a Cake Addin #addin nuget:?package=LinqAsync.EFCore&version=1.1.0 // Install LinqAsync.EFCore as a Cake Tool #tool nuget:?package=LinqAsync.EFCore&version=1.1.0
LinqAsync
This package allow you to do the asynchronous query with IQueryable. Implements async query interface IAsyncQueryableMethodsProvider for your code.
Nuget packages
Name | Version | Downloads |
---|---|---|
LinqAsync | ||
LinqAsync.EFCore |
Usage
Here is an implementation of IAsyncQueryableMethodsProvider for Entity Framework Core.
Abstraction layer project
The abstraction layer project does not know/implement any async method of the underlying db. It's just focus the business logic in here.
There is no technical implementation here
Install the NuGet package from nuget.org
PM> Install-Package LinqAsync
The following code example does a query for Contract. Use async method FirstOrDefaultAsync to find the first item.
public interface IContactRepository : IQueryable<Contact>
{
}
public class ContactQuery
{
private readonly IContactRepository _repo;
public ContactQuery(IContactRepository repo)
{
_repo = repo;
}
public Task<Contact?> GetContactOrDefaultAsync(Guid id)
{
var q = from x in _repo
where x.Id == id
select x;
// Here we can use the static extension method for async query without EFCore dependences.
return _repo.FirstOrDefaultAsync(q);
}
}
Repo implementation with EFCore project
This project will install EFCore packages and LinqAsync.EFCore
Install the NuGet package from nuget.org
PM> Install-Package LinqAsync.EFCore
Then we just register the EFCore async query implement to AsyncQueryableExtensions, no more code needed.
// register async query EFCore implementation to AsyncQueryableExtensions at startup
var efCoreAsyncQueryable = new EntityFrameworkCoreAsyncQueryableMethodsProvider();
AsyncQueryableExtensions.RegisterAsyncQueryableMethodsProvider(efCoreAsyncQueryable);
All async query will pass-thru the provider (EntityFrameworkCoreAsyncQueryableMethodsProvider in this case) to make async query in Entity Framework Core.
Final
Leave a comment on GitHub if you have any questions or suggestions.
Turn on the "Star" icon to support if you like it.
License
This project is licensed under the MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- LinqAsync (>= 1.1.0)
- Microsoft.EntityFrameworkCore (>= 3.1.0)
-
net6.0
- LinqAsync (>= 1.1.0)
- Microsoft.EntityFrameworkCore (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.