Almostengr.Common
10.2026.718.2325
dotnet add package Almostengr.Common --version 10.2026.718.2325
NuGet\Install-Package Almostengr.Common -Version 10.2026.718.2325
<PackageReference Include="Almostengr.Common" Version="10.2026.718.2325" />
<PackageVersion Include="Almostengr.Common" Version="10.2026.718.2325" />
<PackageReference Include="Almostengr.Common" />
paket add Almostengr.Common --version 10.2026.718.2325
#r "nuget: Almostengr.Common, 10.2026.718.2325"
#:package Almostengr.Common@10.2026.718.2325
#addin nuget:?package=Almostengr.Common&version=10.2026.718.2325
#tool nuget:?package=Almostengr.Common&version=10.2026.718.2325
Almostengr Common Utilities
C# library with code that I often use with custom applications. This library includes the Result pattern and generics for database driven applications. These include, but are not limited to, methods and classes to make changes to entities, generic repository methods, and generic service classes.
By using this class library, it reduces the needs to code common functionality and features in every application that I am creating.
Entity Types
LookupEntity
This type should be used as a base class for any lookup values. Examples include, but is not limited to, states, gender, bank account types, etc. It has predefined properties that are often used with lookup types, but can be extended to fit the type of your creation.
Entity
Entity should be used for any other type of entity that does not meet any of the above criteria. Examples of this includes, but is not limited to, people, car brands, and other real world objects that need to be modeled in your application.
Program.cs Updates
Below is the code that you will need to add to your Program.cs file. Ideally add it after any database configuration, but before any dependent services, such as controllers.
builder.Services.AddCommonServices();
Example Entity Implementation
public class Person : Entity
{
public string FirstName {get;private set;}
// other properties related to the entity
}
Example Repository Layer Implementation
public sealed class PersonRepository<Person> : QueryRepository<Person>, IQueryRepository<Person>
{
public PersonRepository(ApplicationDbContext dbContext) : base(dbContext)
{}
public async Task<Person> GetByFirstNameAsync(string firstName)
{
return await _dbSet
.Where(p => p.FirstName == firstName)
.SingleOrDefaultAsync();
}
// additional service methods here
}
Example Service Layer Implementation
public sealed class QueryPersonService<Person, PersonResource> : IQueryService<Person, PersonResource>
{
private readonly IPersonRepository<Person> _repository;
public QueryPersonService(IPersonRepository<Person> repository)
{
_repository = repository;
}
// additional service methods here
}
Example API Key Middleware
In the Program.cs file, add the below:
app.UserMiddleware<ApiKeyMiddleware>();
Also add one of the following (not both) to the Program.cs file:
builder.Services.AddApiKeySettingsServices();
or
builder.Services.AddApiKeyDbServices();
In your ApplicationDbContext.cs file, or similarly named file for your DbContext, add the following:
public required DbSet<ApiKey> ApiKeys {get; set;}
Issues and Feature Requests
Any issues, bugs, or feature requests for this library, should be submitted to its Github repository. When submitting the request, be sure to use the appropriate template. Requests that are not submitted using the appropriate template, may be ignored or rejected.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- MailKit (>= 4.17.0)
- Microsoft.AspNetCore.Identity.UI (>= 10.0.9)
- Microsoft.AspNetCore.Mvc (>= 2.3.11)
- Microsoft.EntityFrameworkCore (>= 10.0.9)
- Square (>= 44.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Almostengr.Common:
| Package | Downloads |
|---|---|
|
Almostengr.MgmInsights.Common
Common generic classes and methods used for building MVC and Web API applications. |
|
|
Almostengr.FalconPiPlayer.ApiClient
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.2026.718.2325 | 117 | 7/18/2026 |
| 10.2026.708.236 | 114 | 7/8/2026 |
| 10.2026.403.917 | 146 | 4/3/2026 |
| 9.2025.10.912 | 220 | 10/9/2025 |
| 9.2025.8.2203 | 223 | 8/22/2025 |
| 9.2025.8.1502 | 200 | 8/15/2025 |
| 9.2025.6.601 | 191 | 6/6/2025 |
| 9.2025.6.101 | 167 | 6/1/2025 |
| 8.2025.5.28 | 209 | 5/28/2025 |