F2.Repository
8.0.11
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package F2.Repository --version 8.0.11
NuGet\Install-Package F2.Repository -Version 8.0.11
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="F2.Repository" Version="8.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add F2.Repository --version 8.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: F2.Repository, 8.0.11"
#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 F2.Repository as a Cake Addin #addin nuget:?package=F2.Repository&version=8.0.11 // Install F2.Repository as a Cake Tool #tool nuget:?package=F2.Repository&version=8.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
F2.Repository
Simple definitions for repository pattern
- Basic CRUD implemented
- Basic Context scope (aka ~UnitOfWork)
GenericRepository
,GenericEntityRepository
with and withoutPrimaryKey
- Abstracts implement
IQueryable
, example:_customerRepository.Where(...)
SecureGuidValueGenerator
,DateTimeValueGenerator
,ITimestampedEntity
- By convention, a property named Id or <type name>Id will be configured as the primary key of an entity
Getting started
1. Install Nuget package F2.Repository
Install-Package F2.Repository
2. Implement IEntity<TKey>
on your models
Or, you can create your own BaseEntity
:
public abstract class BaseEntity : IEntity<Guid>, ITimestampedEntity
{
public Guid Id { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
public class Book : BaseEntity
{
public string Title { get; set; }
public string Isbn { get; set; }
public virtual ICollection<Author> Authors { get; set; }
}
Create your configuration (see example)
public class BookEntityConfiguration : IEntityTypeConfiguration<Book>
{
public void Configure(EntityTypeBuilder<Book> builder)
{
builder.UseAutoGeneratedId();
builder.UseTimestampedProperty();
builder.HasMany(s => s.Authors).WithMany(s => s.Books);
}
}
3. Implement your repository
GenericEntityRepository<TEntityType>
or GenericRepository<TEntityType>
abstracts
using F2.Repository.Abstracts;
public class CustomerRepository : GenericEntityRepository<Customer>
{
public CustomerRepository(YourDbContext context) : base(context)
{
}
}
4. Create Database Context Scope
public class YourDbScope : DbContextScope<YourDbContext>
{
public YourDbScope(YourDbContext context) : base(context)
{
YourRepository = yourRepository;
}
public YourRepository YourRepository { get; }
}
5. Register Scope and repositories to DI
All repositories will automatically registered for DI
services.AddDatabaseScope<YourDbContext>();
// ... services.AddDbContext<AutomateContext>(opts => opts.UseSqlServer(_configuration.GetConnectionString("SqlConnection"));
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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.
-
net8.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.EntityFrameworkCore (>= 8.0.11)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.11)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on F2.Repository:
Package | Downloads |
---|---|
F2.Infrastructure
Basic infrastructure |
GitHub repositories
This package is not used by any popular GitHub repositories.