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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AzureGems.Repository.Abstractions" Version="3.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AzureGems.Repository.Abstractions --version 3.0.1                
#r "nuget: AzureGems.Repository.Abstractions, 3.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
3.0.1 665 2/23/2023
3.0.0 353 2/23/2023
2.1.0 1,194 2/21/2021
2.0.0 1,229 2/9/2021
1.2.1 3,656 3/13/2020
1.2.0 1,089 3/13/2020
1.1.0 1,096 1/22/2020
1.0.0 1,115 1/5/2020