RandomRepo 1.0.0

dotnet add package RandomRepo --version 1.0.0
                    
NuGet\Install-Package RandomRepo -Version 1.0.0
                    
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="RandomRepo" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RandomRepo" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RandomRepo" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RandomRepo --version 1.0.0
                    
#r "nuget: RandomRepo, 1.0.0"
                    
#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.
#:package RandomRepo@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RandomRepo&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RandomRepo&version=1.0.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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