ICommandor 1.0.6

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

Commandor

O'rnatish

dotnet add package ICommandor

Ishlatish

using Commandor;

public interface IColorService : ICommandorService
{
    [QueryHandler]
    Task<List<ColorEntity>> GetAll(GetAllColorsQuery query, CancellationToken ct = default);

    [QueryHandler]
    Task<ColorEntity?> GetById(GetColorQuery query, CancellationToken ct = default);

    [CommandHandler]
    Task<ColorEntity> Create(CreateColorCommand command, CancellationToken ct = default);

    [CommandHandler]
    Task Update(UpdateColorCommand command, CancellationToken ct = default);
}

public class ColorService : IColorService
{
    public virtual Task<ColorEntity> Create(CreateColorCommand command, CancellationToken ct = default) => throw new NotImplementedException();
    public virtual Task<List<ColorEntity>> GetAll(GetAllColorsQuery query, CancellationToken ct = default) => throw new NotImplementedException();
    public virtual Task<ColorEntity?> GetById(GetColorQuery query, CancellationToken ct = default) => throw new NotImplementedException();
    public virtual Task Update(UpdateColorCommand command, CancellationToken ct = default) => throw new NotImplementedException();
}

var services = new ServiceCollection();
services.AddCommandor();
services.AddCommandorService<IColorService, ColorService>();

Cache

  • [QueryHandler] natijalari cache'lanadi.
  • [CommandHandler] bajarilganda cache tozalanadi (IComputedCache.Clear()).

?? Muhim Eslatmalar

Command/Query Pattern

Commandor'da barcha method parametrlari IRequest<TResponse> yoki IRequest implement qilishi kerak. Primitive type'larni to'g'ridan-to'g'ri ishlatish mumkin emas.

? Noto'g'ri:

public interface ITodoService : ICommandorService
{
    [CommandHandler]
    Task<Todo> CreateTodoAsync(string title);  // ? string - IRequest emas
    
    [QueryHandler]
    Task<Todo?> GetTodoByIdAsync(int id);  // ? int - IRequest emas
}

? To'g'ri:

// Request/Query record'larni yaratish
public record CreateTodoCommand(string Title) : IRequest<Todo>;
public record GetTodoByIdQuery(int Id) : IRequest<Todo?>;

public interface ITodoService : ICommandorService
{
    [CommandHandler]
    Task<Todo> CreateTodoAsync(CreateTodoCommand command, CancellationToken ct = default);
    
    [QueryHandler]
    Task<Todo?> GetTodoByIdAsync(GetTodoByIdQuery query, CancellationToken ct = default);
}

Method Naming

Method nomlari uchun quyidagi konvensiyalarni tavsiya qilamiz:

  • Command'lar uchun: Create..., Update..., Delete..., Process...
  • Query'lar uchun: Get..., Find..., List..., Search...

Cache Invalidation

CommandHandler'lar avtomatik cache'ni tozalamaydi! Agar command'dan keyin query cache'ini invalidate qilish kerak bo'lsa, service implementation'ida qo'lda qiling:

public class TodoService(AppDbContext db, IComputedCache cache) : ITodoService
{
    public async Task<Todo> UpdateTodoAsync(UpdateTodoCommand cmd, CancellationToken ct)
    {
        var todo = await db.Todos.FindAsync([cmd.Id], ct);
        if (todo != null)
        {
            todo.Title = cmd.Title;
            await db.SaveChangesAsync(ct);
            
            // Cache'ni qo'lda invalidate qilish
            var cacheKey = CacheKeyBuilder.Build(
                typeof(ITodoService),
                nameof(GetTodoByIdAsync),
                new GetTodoByIdQuery(cmd.Id));
            cache.Remove(cacheKey);
        }
        return todo;
    }
}
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 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

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.1.0 1,065 12/30/2025
1.0.6 1,777 12/22/2025
1.0.5 1,772 12/22/2025
1.0.4 1,789 12/22/2025
1.0.3 1,794 12/22/2025
1.0.2 1,797 12/22/2025
1.0.1 2,328 12/15/2025
1.0.0 3,776 11/18/2025

test