RandomRepo 1.0.0
dotnet add package RandomRepo --version 1.0.0
NuGet\Install-Package RandomRepo -Version 1.0.0
<PackageReference Include="RandomRepo" Version="1.0.0" />
<PackageVersion Include="RandomRepo" Version="1.0.0" />
<PackageReference Include="RandomRepo" />
paket add RandomRepo --version 1.0.0
#r "nuget: RandomRepo, 1.0.0"
#:package RandomRepo@1.0.0
#addin nuget:?package=RandomRepo&version=1.0.0
#tool nuget:?package=RandomRepo&version=1.0.0
RandomRepo
A simple library written in .NET 8 which helps in implementing the Repository pattern.
Installation
Install with NuGet:
Install-Package RandomRepo
or with .NET CLI:
dotnet add package RandomRepo
Using the package
The RandomRepo.Tests folder contains an example of how the package can be implemented.
For any data set that you'll make queries for, you'll need to make an interface and a class with the proper hierarchy:
public interface IUserRepository : IRepository<User>
{
}
public class UserRepository : Repository<User, DemoDbContext>, IUserRepository
{
public UserRepository(DemoDbContext dbContext) : base(dbContext)
{
}
}
The class also inherits the Repository abstract class, which uses the given DbContext to make queries. The newly added interface and class should be registered in the DI container. Once this has been done, you could inject it in whatever class you need and make queries with it:
public class UserService
{
private readonly IUserRepository _userRepository;
public UserService(IUserRepository userRepository)
{
_userRepository = userRepository;
}
public User GetUserByName(string name)
{
return _userRepository.GetFirst(u => u.Username == name);
}
}
This project is made for educational purposes only!
| 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 199 | 7/4/2024 |