When attempting to retrieve data using the GetListQueryHandler, the system consistently returns the default ID 00000000-0000-0000-0000-000000000000. This issue introduces confusion and has the potential to lead to errors in data interpretation.
Code snippet:
GetListQueryHandler.cs
public sealed class GetListQueryHandler(Repository<Category> repository)
: IQueryHandler<GetListQuery, Result<List<CategoryVm>>>
{
public async Task<Result<List<CategoryVm>>> Handle(GetListQuery request, CancellationToken cancellationToken)
{
var result = await repository.ListAsync(cancellationToken);
return Result<List<CategoryVm>>.Success([
..result.Select(c => new CategoryVm(
c.Id,
c.Name,
c.Description
))
]);
}
}
Category.cs
public sealed class Category : EntityBase, IAggregateRoot
{
/// <summary>
/// EF mapping constructor
/// </summary>
public Category()
{
}
public Category(string title, string? description)
{
Name = Guard.Against.NullOrEmpty(title);
Description = description;
}
public CategoryId Id { get; set; } = new(Guid.NewGuid());
public string? Name { get; set; }
public string? Description { get; set; }
}
[StronglyTypedId]
public readonly partial struct CategoryId;
CategoryVm.cs
public sealed record CategoryVm(
CategoryId Id,
string? Name,
string? Description
);
Problem:
When attempting to retrieve data using the GetListQueryHandler, the system consistently returns the default ID 00000000-0000-0000-0000-000000000000. This issue introduces confusion and has the potential to lead to errors in data interpretation.
Code snippet:
GetListQueryHandler.cs
Category.cs
CategoryVm.cs
Screenshots
Data in database
Data when response