ProfileService 1.2.2
See the version list below for details.
dotnet add package ProfileService --version 1.2.2
NuGet\Install-Package ProfileService -Version 1.2.2
<PackageReference Include="ProfileService" Version="1.2.2" />
<PackageVersion Include="ProfileService" Version="1.2.2" />
<PackageReference Include="ProfileService" />
paket add ProfileService --version 1.2.2
#r "nuget: ProfileService, 1.2.2"
#:package ProfileService@1.2.2
#addin nuget:?package=ProfileService&version=1.2.2
#tool nuget:?package=ProfileService&version=1.2.2
ProfileLib
A lightweight, extensible profile management library for .NET applications that provides a clean architecture approach to handling profile data with dynamic query building.
Features
- 🎯 Base profile entity with audit properties
- 💾 Generic repository pattern
- 🔍 Dynamic query building with type safety
- 📄 Built-in pagination support
- 🗃️ Multiple database provider support
- 🧱 Easy to extend and customize
Installation
dotnet add package ProfileLib
Add your preferred database provider:
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
# or
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
# or
dotnet add package Pomelo.EntityFrameworkCore.MySql
# or
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
Usage
- Create your profile class:
public class CustomerProfile : ProfileBase
{
public string? CompanyName { get; private set; }
public string? Department { get; private set; }
private CustomerProfile() : base() { }
public static CustomerProfile Create(string name, string email, string? companyName = null)
{
return new CustomerProfile
{
Name = name,
Email = email.ToLower(),
CompanyName = companyName
};
}
}
- Create your repository:
public class CustomerProfileRepository : BaseProfileRepository<CustomerProfile>
{
public CustomerProfileRepository(
CustomerDbContext context,
ILogger<CustomerProfileRepository> logger)
: base(context, logger)
{
}
}
- Configure services:
services.AddProfileService<CustomerProfile, CustomerDbContext, CustomerProfileRepository>(
Configuration,
Configuration.GetConnectionString("DefaultConnection")!,
DatabaseProvider.SQLServer);
- Use the QueryBuilder:
public class CustomerService
{
private readonly IProfileRepositoryBase<CustomerProfile> _repository;
public async Task<List<CustomerProfile>> SearchAsync(string? name, string? company)
{
var predicate = new QueryBuilder<CustomerProfile>()
.WhenNotNullOrEmpty(name, x => x.Name.Contains(name))
.WhenNotNullOrEmpty(company, x => x.CompanyName == company)
.Build();
return await _repository.Query()
.FindAsync(predicate, "Name", take: 10);
}
public async Task<(List<CustomerProfile>, int)> GetPaginatedAsync(
string? name,
string? company,
int page = 1,
int pageSize = 10)
{
var predicate = new QueryBuilder<CustomerProfile>()
.WhenNotNullOrEmpty(name, x => x.Name.Contains(name))
.WhenNotNullOrEmpty(company, x => x.CompanyName == company)
.Build();
return await _repository.Query()
.PaginateAsync(predicate, "Name", pageNumber: page, pageSize: pageSize);
}
}
Query Building
The QueryBuilder<T> provides fluent methods for building type-safe queries:
var predicate = new QueryBuilder<CustomerProfile>()
.WithCondition(x => x.Status == ProfileStatus.Active)
.WhenNotNull(company, x => x.CompanyName == company)
.WhenHasValue(salary, x => x.Salary >= salary)
.WhenNotNullOrEmpty(name, x => x.Name.Contains(name))
.Build();
Supported Database Providers
- SQL Server
- PostgreSQL
- MySQL
- SQLite
Base Profile Properties
public abstract class ProfileBase
{
public Guid Id { get; protected set; }
public string Name { get; protected set; }
public string Email { get; protected set; }
public DateTime CreatedAt { get; protected set; }
public DateTime? UpdatedAt { get; protected set; }
public string? CreatedBy { get; protected set; }
public string? UpdatedBy { get; protected set; }
public ProfileStatus Status { get; protected set; }
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
ProfileLib
A flexible and extensible profile management library for .NET applications with support for multiple database providers, built with Clean Architecture principles.
Features
- 🎯 Clean Architecture Design
- 💾 Multiple Database Provider Support
- SQL Server
- PostgreSQL
- MySQL
- SQLite
- 🔄 Generic Repository Pattern
| 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
- FluentValidation (>= 11.9.0)
- Microsoft.EntityFrameworkCore (>= 8.0.0)
- Microsoft.EntityFrameworkCore.InMemory (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Sqlite (>= 8.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.0)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Caching.Memory (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.0)
- Pomelo.EntityFrameworkCore.MySql (>= 8.0.0-beta.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.