Franz.Common.Business
1.3.3
See the version list below for details.
dotnet add package Franz.Common.Business --version 1.3.3
NuGet\Install-Package Franz.Common.Business -Version 1.3.3
<PackageReference Include="Franz.Common.Business" Version="1.3.3" />
<PackageVersion Include="Franz.Common.Business" Version="1.3.3" />
<PackageReference Include="Franz.Common.Business" />
paket add Franz.Common.Business --version 1.3.3
#r "nuget: Franz.Common.Business, 1.3.3"
#:package Franz.Common.Business@1.3.3
#addin nuget:?package=Franz.Common.Business&version=1.3.3
#tool nuget:?package=Franz.Common.Business&version=1.3.3
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
Contributing
This package is part of the private Franz Framework. Authorized contributors:
- Clone repo.
- Create a feature branch.
- 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
Product | Versions 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. |
-
net9.0
- Franz.Common.DependencyInjection (>= 1.3.3)
- Franz.Common.Errors (>= 1.3.3)
- Franz.Common.Mediator (>= 1.3.3)
- MediatR (>= 13.0.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.8)
- Scrutor (>= 6.1.0)
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 |