AzureGems.Repository.Abstractions
3.0.1
dotnet add package AzureGems.Repository.Abstractions --version 3.0.1
NuGet\Install-Package AzureGems.Repository.Abstractions -Version 3.0.1
<PackageReference Include="AzureGems.Repository.Abstractions" Version="3.0.1" />
paket add AzureGems.Repository.Abstractions --version 3.0.1
#r "nuget: AzureGems.Repository.Abstractions, 3.0.1"
// Install AzureGems.Repository.Abstractions as a Cake Addin #addin nuget:?package=AzureGems.Repository.Abstractions&version=3.0.1 // Install AzureGems.Repository.Abstractions as a Cake Tool #tool nuget:?package=AzureGems.Repository.Abstractions&version=3.0.1
AzureGems Repository - Abstractions
This library provides a CRUD interface for a Generic Repository. The interface also allows you to write LINQ expressions via the Query()
method.
IRepository<T>
The IRepository
interface does not provide methods that return an IQueryable
as it is generally considered to be an anti-pattern.
Instead, the interface provides a Query()
method so that you can write Expressions against a provided IQueryable
parameter.
For example:
private readonly IRepository<Widget> _widgets;
public IEnumerable<Widget> GetWidgetsBelow(double price)
{
return _widgets.Query(q => q.Where(w => w.SalePrice < price));
}
In the code above, q
is of type IQueryable<Widget>
and w
is of type Widget
.
Returning custom models
Each repository is strongly typed and most of the CRUD methods will only return a single/enumerable of the same strong type.
However when using the LINQ Expression with the Query()
method we are able to return custom models (view models) using the LINQ .Select()
operator.
For example:
IEnumerable<WidgetViewModel> spinners = await widgetsRepo.Query(q => q
.Where(w => w.Type == "Spinner")
.OrderBy(w => w.Style)
.Select(s => new WidgetViewModel()
{
DisplayName = s.Name + " Spinner",
Price = s.SalePrice
})
);
NOTE: Returning Anonymous types aren't supported!
Using BaseEntity
This type is used as a generic constraint for the IRepository<T>
interface. This means any model of type T
must inherit from BaseEntity
It provides the required Id
field and the Discriminator
field to be used with all models.
TODO: Can BaseEntity
be moved to the AzureGems.Repository.CosmosDb implementation?
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
- Newtonsoft.Json (>= 13.0.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on AzureGems.Repository.Abstractions:
Package | Downloads |
---|---|
AzureGems.Repository.CosmosDB
Cosmos DB implementation for the Repository pattern. |
|
AzureGems.SpendOps.CosmosDB
SpendOps extensions for AzureGems Cosmos DB. |
GitHub repositories
This package is not used by any popular GitHub repositories.