Franz.Common.Business 1.3.0

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

Got it ✅ — your doc currently repeats some concepts (entities, value objects, aggregates) both under Features and Usage, and the changelog also shows up twice. I’ll restructure it so it:

  • Keeps the novelties (like aggregates being event-sourced in 1.2.65, mediator separation in 1.3).
  • Explains each feature once, with examples where useful.
  • Flows in a clean order: Overview → Features → Usage → Dependencies → Installation → Contribution → License → Changelog.

Here’s a cleaned-up version:


Franz.Common.Business

A core library of the Franz Framework, designed to facilitate Domain-Driven Design (DDD) and CQRS (Command Query Responsibility Segregation) in .NET applications. It provides abstractions, utilities, and patterns for building scalable, maintainable, and testable business logic.


Features

1. Domain-Driven Design (DDD) Building Blocks

  • Entities: Represent unique objects identified by a primary key.
  • Value Objects: Immutable, equality-driven domain concepts.
  • Enumerations: Strongly typed enums with behavior and metadata.
  • Repositories: Interfaces for persistence (IAggregateRepository<TAggregateRoot>, IReadRepository<T>).

Example Entity:

public class Order : Entity<Guid>
{
    public string CustomerName { get; private set; }
    public decimal TotalAmount { get; private set; }

    public Order(Guid orderId, string customerName, decimal totalAmount)
    {
        Id = orderId;
        CustomerName = customerName;
        TotalAmount = totalAmount;
    }
}

Example Value Object:

public class Address : ValueObject
{
    public string Street { get; }
    public string City { get; }
    public string PostalCode { get; }

    public Address(string street, string city, string postalCode)
    {
        Street = street;
        City = city;
        PostalCode = postalCode;
    }

    protected override IEnumerable<object> GetEqualityComponents()
    {
        yield return Street;
        yield return City;
        yield return PostalCode;
    }
}

2. Aggregates (Event-Sourced)

🆕 Since 1.2.65, aggregates follow a strict event-driven model:

  • Enforce consistency across related entities.
  • State is modified only through events.
  • Support replay via event sourcing.
  • Always identified by Guid.

Example:

public class Product : EventSourcedAggregateRoot<ProductEvent>
{
    public string Name { get; private set; }
    public decimal Price { get; private set; }
    private readonly List<ProductReview> _reviews = new();
    public IReadOnlyCollection<ProductReview> Reviews => _reviews.AsReadOnly();

    public Product(Guid id, string name, decimal price) : base(id)
    {
        RaiseEvent(new ProductCreatedEvent(id, name, price));
    }

    public void UpdatePrice(decimal newPrice)
    {
        if (newPrice <= 0) throw new InvalidOperationException("Price must be positive.");
        RaiseEvent(new ProductPriceUpdatedEvent(Id, newPrice));
    }

    public void AddReview(string comment, int rating)
    {
        if (rating < 1 || rating > 5) throw new InvalidOperationException("Rating must be between 1 and 5.");
        RaiseEvent(new ProductReviewAddedEvent(Id, comment, rating));
    }

    public void Apply(ProductCreatedEvent @event) { Id = @event.ProductId; Name = @event.Name; Price = @event.Price; }
    public void Apply(ProductPriceUpdatedEvent @event) { Price = @event.NewPrice; }
    public void Apply(ProductReviewAddedEvent @event) { _reviews.Add(new ProductReview(@event.Comment, @event.Rating)); }
}

3. Events

Supports both domain events and integration events. Core abstractions:

  • IEvent
  • IEventHandler<TEvent>
  • IntegrationEvent
  • BaseEvent

Example:

public class OrderCreatedEvent : IEvent
{
    public Guid OrderId { get; set; }
    public string CustomerName { get; set; }
}

public class OrderCreatedHandler : IEventHandler<OrderCreatedEvent>
{
    public async Task Handle(OrderCreatedEvent @event, CancellationToken cancellationToken)
    {
        Console.WriteLine($"Order created for {@event.CustomerName}.");
    }
}

4. CQRS Support

  • Commands (ICommandRequest<T>, ICommandHandler<TCommand,TResponse>)
  • Queries (IQueryRequest<T>, IQueryHandler<TQuery,TResponse>)

Command Example:

public class CreateOrderCommand : ICommandRequest<Guid>
{
    public string CustomerName { get; set; }
    public decimal TotalAmount { get; set; }
}

public class CreateOrderHandler : ICommandHandler<CreateOrderCommand, Guid>
{
    public async Task<Guid> Handle(CreateOrderCommand request, CancellationToken cancellationToken)
    {
        var orderId = Guid.NewGuid();
        Console.WriteLine($"Order created for {request.CustomerName} with ID: {orderId}");
        return orderId;
    }
}

5. Extensions & Utilities

  • ServiceCollectionExtensions: Registers command, query, and event handlers with DI.
  • HandlerCollector: Auto-discovers handlers.
  • TypeExtensions: Reflection and type utilities.
services.AddBusinessServices(); // Registers all handlers automatically

Dependencies

  • MediatR (13.0.0) – mediator pattern.
  • Scrutor (4.2.2) – assembly scanning & DI.
  • Microsoft.Extensions.DependencyInjection (9.0.0) – DI support.
  • Franz.Common.DependencyInjection – core DI patterns.
  • Franz.Common.Errors – standardized error handling.

Installation

From Private Azure Feed

dotnet nuget add source "https://your-private-feed-url" \
  --name "AzurePrivateFeed" \
  --username "YourAzureUsername" \
  --password "YourAzurePassword" \
  --store-password-in-clear-text
dotnet add package Franz.Common.Business --Version 1.3

Contributing

This package is part of the private Franz Framework. Authorized contributors:

  1. Clone repo.
  2. Create a feature branch.
  3. Submit a PR for review.

Changelog

1.3

  • Upgraded to .NET 9
  • Compatible with in-house mediator library & MediatR
  • Clear separation between business and mediator concepts

1.2.65

  • Aggregates redesigned to use event sourcing
  • All aggregates now require a Guid identifier

This way:

  • No duplication (Entities, Value Objects, Aggregates appear only once under Features).
  • Novelties highlighted in Changelog and Features.
  • Usage examples streamlined under each feature instead of repeated in a separate Usage section.

Would you like me to also split this into a README.md format with collapsible sections (like GitHub <details> tags for examples), so it’s cleaner for developers browsing the repo?

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 (6)

Showing the top 5 NuGet packages that depend on Franz.Common.Business:

Package Downloads
Franz.Common.EntityFramework

Shared utility library for the Franz Framework.

Franz.Common.Messaging

Shared utility library for the Franz Framework.

Franz.Common.Serialization

Shared utility library for the Franz Framework.

Franz.Common.Bootstrap

Shared utility library for the Franz Framework.

Franz.Common.Http.Documentation

Shared utility library for the Franz Framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.3 16 9/21/2025
1.5.2 21 9/21/2025
1.5.0 26 9/21/2025
1.4.4 75 9/20/2025
1.3.14 244 9/18/2025
1.3.13 235 9/18/2025
1.3.5 267 9/17/2025
1.3.4 297 9/16/2025
1.3.3 305 9/16/2025
1.3.2 304 9/15/2025
1.3.1 124 9/12/2025
1.3.0 329 8/25/2025
1.2.65 280 3/3/2025
1.2.64 221 1/29/2025
1.2.63 263 1/27/2025
1.2.62 272 1/8/2025