YDotNet.Repository
1.0.1
dotnet add package YDotNet.Repository --version 1.0.1
NuGet\Install-Package YDotNet.Repository -Version 1.0.1
<PackageReference Include="YDotNet.Repository" Version="1.0.1" />
<PackageVersion Include="YDotNet.Repository" Version="1.0.1" />
<PackageReference Include="YDotNet.Repository" />
paket add YDotNet.Repository --version 1.0.1
#r "nuget: YDotNet.Repository, 1.0.1"
#addin nuget:?package=YDotNet.Repository&version=1.0.1
#tool nuget:?package=YDotNet.Repository&version=1.0.1
🚀 Generic Repository Pattern
This project provides a generic repository pattern implementation for .NET applications using Entity Framework Core. Inspired by Java Spring's repository approach, this abstraction layer helps separate business logic from data access logic, making your application more maintainable, scalable, and testable.
✨ Features
✅ Generic repository that works with any entity type
✅ Async/await support for improved performance
✅ CRUD operations (Create, Read, Update, Delete)
✅ Type-safe operations with generic type parameters
✅ Built on top of Entity Framework Core
📦 Installation
🚧 Coming soon (NuGet package setup in progress)
📌 Usage
1️⃣ Define Your Entity
Your entity class must implement the IEntity
interface:
public class YourEntity : IEntity
{
public int Id { get; set; }
// ... other properties
}
2️⃣ Create a Repository
Create a specific repository for your entity by inheriting from the base Repository
class:
public class YourEntityRepository : Repository<YourEntity, int>
{
public YourEntityRepository(DbContext context) : base(context)
{
}
}
3️⃣ Use the Repository
// In your service or controller:
public class YourService
{
private readonly YourEntityRepository _repository;
public YourService(YourEntityRepository repository)
{
_repository = repository;
}
public async Task<YourEntity?> GetEntityById(int id)
{
return await _repository.GetByIdAsync(id);
}
public async Task<IEnumerable<YourEntity>> GetAllEntities()
{
return await _repository.GetAllAsync();
}
}
🔧 Available Methods
GetByIdAsync(TIdentifier id)
: 🔍 Retrieves an entity by its IDAdd(TEntity entity)
: ➕ Adds a new entityUpdate(TEntity entity)
: 🔄 Updates an existing entityDelete(TEntity entity)
: 🗑️ Removes an entityGetAllAsync()
: 📜 Retrieves all entities
📌 Dependencies
- Microsoft.EntityFrameworkCore
🤝 Contributing
Contributions are welcome! 🎉 Feel free to submit issues, bug fixes, or feature requests.
📜 License
📝 MIT License – Free to use and modify!
This version makes the README more engaging while keeping it professional and informative. Let me know if you’d like any additional tweaks! 🚀😊
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. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.13)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.