ProfileService 1.2.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package ProfileService --version 1.2.2
                    
NuGet\Install-Package ProfileService -Version 1.2.2
                    
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="ProfileService" Version="1.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProfileService" Version="1.2.2" />
                    
Directory.Packages.props
<PackageReference Include="ProfileService" />
                    
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 ProfileService --version 1.2.2
                    
#r "nuget: ProfileService, 1.2.2"
                    
#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 ProfileService@1.2.2
                    
#: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=ProfileService&version=1.2.2
                    
Install as a Cake Addin
#tool nuget:?package=ProfileService&version=1.2.2
                    
Install as a Cake Tool

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

  1. 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
        };
    }
}
  1. Create your repository:
public class CustomerProfileRepository : BaseProfileRepository<CustomerProfile>
{
    public CustomerProfileRepository(
        CustomerDbContext context,
        ILogger<CustomerProfileRepository> logger)
        : base(context, logger)
    {
    }
}
  1. Configure services:
services.AddProfileService<CustomerProfile, CustomerDbContext, CustomerProfileRepository>(
    Configuration,
    Configuration.GetConnectionString("DefaultConnection")!,
    DatabaseProvider.SQLServer);
  1. 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 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.2.7 169 11/24/2024
1.2.6 106 11/23/2024
1.2.5 106 11/17/2024
1.2.2 104 11/16/2024
1.2.1 100 11/16/2024
1.2.0 102 11/16/2024
1.1.0 107 11/13/2024
1.0.1 156 11/13/2024
1.0.0 168 11/12/2024