- added intelligent mapping when targeting a Nox table #3694
Annotations
12 errors and 12 warnings
Nox.Generator.Tests.Application.EtlDtoTests ► Can_Generate_dtos_for_entity_target:
tests/Nox.Generator.Tests/TestResults/test-results.trx#L0
Failed test found in:
tests/Nox.Generator.Tests/TestResults/test-results.trx
Error:
Expected collection Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Domain/TestEntity.g.cs",
SourceText = // Generated
#nullable enable
using System;
using System.Collections.Generic;
using MediatR;
using Nox.Abstractions;
using Nox.Domain;
using Nox.Solution;
using Nox.Types;
using Nox.Extensions;
using Nox.Exceptions;
namespace TestIntegrationSolution.Domain;
public partial class TestEntity : TestEntityBase, IEntityHaveDomainEvents
{
///<inheritdoc/>
public void RaiseCreateEvent()
{
InternalRaiseCreateEvent(this);
}
///<inheritdoc/>
public void RaiseDeleteEvent()
{
InternalRaiseDeleteEvent(this);
}
///<inheritdoc/>
public void RaiseUpdateEvent()
{
InternalRaiseUpdateEvent(this);
}
}
/// <summary>
/// Record for TestEntity created event.
/// </summary>
public record TestEntityCreated(TestEntity TestEntity) : IDomainEvent, INotification;
/// <summary>
/// Record for TestEntity updated event.
/// </summary>
public record TestEntityUpdated(TestEntity TestEntity) : IDomainEvent, INotification;
/// <summary>
/// Record for TestEntity deleted event.
/// </summary>
public record TestEntityDeleted(TestEntity TestEntity) : IDomainEvent, INotification;
/// <summary>
/// Test Entity and related data.
/// </summary>
public abstract partial class TestEntityBase : AuditableEntityBase, IEtag
{
/// <summary>
/// Country unique identifier
/// </summary>
/// <remarks>Required.</remarks>
public Nox.Types.Number Id { get; set; } = null!;
/// <summary>
/// Test Entity's name
/// </summary>
/// <remarks>Required.</remarks>
public Nox.Types.Text Name { get; set; } = null!;
/// <summary>
/// Domain events raised by this entity.
/// </summary>
public IReadOnlyCollection<IDomainEvent> DomainEvents => InternalDomainEvents;
protected readonly List<IDomainEvent> InternalDomainEvents = new();
protected virtual void InternalRaiseCreateEvent(TestEntity testEntity)
{
InternalDomainEvents.Add(new TestEntityCreated(testEntity));
}
protected virtual void InternalRaiseUpdateEvent(TestEntity testEntity)
{
InternalDomainEvents.Add(new TestEntityUpdated(testEntity));
}
protected virtual void InternalRaiseDeleteEvent(TestEntity testEntity)
{
InternalDomainEvents.Add(new TestEntityDeleted(testEntity));
}
/// <summary>
/// Clears all domain events associated with the entity.
/// </summary>
public virtual void ClearDomainEvents()
{
InternalDomainEvents.Clear();
}
/// <summary>
/// Entity tag used as concurrency token.
/// </summary>
public System.Guid Etag { get; set; } = System.Guid.NewGuid();
},
SyntaxTree = // Generated
#nullable enable
using System;
using System.Collections.Generic;
using MediatR;
using Nox.Abstractions;
using Nox.Domain;
using Nox.Solution;
using Nox.Types;
using Nox.Extensions;
using Nox.Exceptions;
namespace TestIntegrationSolution.Domain;
public partial class TestEntity : TestEntityBase, IEntityHaveDomainEvents
{
///<inheritdoc/>
public void RaiseCreateEvent()
{
InternalRaiseCreateEvent(this);
}
///<inheritdoc/>
public void RaiseDeleteEvent()
{
InternalRaiseDeleteEvent(this);
}
///<inheritdoc/>
public void RaiseUpdateEvent()
{
InternalRaiseUpdateEvent(this);
}
}
/// <summary>
/// Record for TestEntity created event.
/// </summary>
public record TestEntityCreated(TestEntity TestEntity) : IDomainEvent, INotification;
/// <summary>
/// Record for TestEntity updated event.
/// </summary>
public record TestEntityUpdated(TestEntity TestEntity) : IDomainEvent, INotification;
/// <summary>
/// Record for TestEntity deleted event.
/// </summary>
public record TestEntityDeleted(TestEntity TestEntity) : IDomainEvent, INotification;
/// <summary>
/// Test Entity and related data.
/// </summary>
public abstract partial class TestEntityBase : AuditableEntityBase, IEtag
{
/// <summary>
/// Country unique identifier
/// </summary>
/// <remarks>Required.</remarks>
public Nox.Types.Number Id { get; set; } = null!;
/// <summary>
/// Test Entity's name
/// </summary>
/// <remarks>Required.</remarks>
public Nox.Types.Text Name { get; set; } = null!;
/// <summary>
/// Domain events raised by this entity.
/// </summary>
public IReadOnlyCollection<IDomainEvent> DomainEvents => InternalDomainEvents;
protected readonly List<IDomainEvent> InternalDomainEvents = new();
protected virtual void InternalRaiseCreateEvent(TestEntity testEntity)
{
InternalDomainEvents.Add(new TestEntityCreated(testEntity));
}
protected virtual void InternalRaiseUpdateEvent(TestEntity testEntity)
{
InternalDomainEvents.Add(new TestEntityUpdated(testEntity));
}
protected virtual void InternalRaiseDeleteEvent(TestEntity testEntity)
{
InternalDomainEvents.Add(new TestEntityDeleted(testEntity));
}
/// <summary>
/// Clears all domain events associated with the entity.
/// </summary>
public virtual void ClearDomainEvents()
{
InternalDomainEvents.Clear();
}
/// <summary>
/// Entity tag used as concurrency token.
/// </summary>
public System.Guid Etag { get; set; } = System.Guid.NewGuid();
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Services/RelationshipChainValidator.g.cs",
SourceText = // Generated
using MediatR;
using Microsoft.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
using Nox.Application.Commands;
using Nox.Application.Services;
using Nox.Domain;
using TestIntegrationSolution.Application.Dto;
using TestIntegrationSolution.Domain;
namespace TestIntegrationSolution.Application.Services;
internal partial class RelationshipChainValidator : RelationshipChainValidatorBase
{
public RelationshipChainValidator(IRepository repository): base(repository)
{
}
}
internal abstract class RelationshipChainValidatorBase: IRelationshipChainValidator
{
private readonly Dictionary<string, (IQueryable Query, string KeyName)> _entityContextPerEntityName;
private readonly Dictionary<string, string> _navigationNameToEntityPluralName;
private readonly Dictionary<(string EntityPluralName, string NavigationName), bool> _isSingleRelationship;
protected IRepository Repository { get; }
#region Constructor
public RelationshipChainValidatorBase(IRepository repository)
{
Repository = repository;
_entityContextPerEntityName = new(StringComparer.OrdinalIgnoreCase)
{
{ "TestEntities", (Repository.Query<TestIntegrationSolution.Domain.TestEntity>(), "Id") }
};
_navigationNameToEntityPluralName = new(StringComparer.OrdinalIgnoreCase)
{
};
_isSingleRelationship = new()
{
};
}
#endregion Constructor
public virtual bool IsValid(RelationshipChain relationshipChain)
{
if (!_entityContextPerEntityName.TryGetValue(relationshipChain.EntityName, out var context))
return false;
if (!TryParseKey(relationshipChain.EntityName, relationshipChain.EntityKey, out var aggregateParsedKey))
return false;
var query = context.Query.Where($"{context.KeyName} == @0", aggregateParsedKey);
var previousAggregateRoot = relationshipChain.EntityName;
var previousKeyName = context.KeyName;
foreach (var property in relationshipChain.SortedNavigationProperties)
{
if (!_isSingleRelationship.TryGetValue((previousAggregateRoot, property.NavigationName), out var isSingle))
return false;
query = query.Select($"new ({previousKeyName}, {property.NavigationName})");
if (isSingle)
query = query.Select($"{property.NavigationName}");
else
query = query.SelectMany($"{property.NavigationName}");
if (!_navigationNameToEntityPluralName.TryGetValue(property.NavigationName, out var relatedPluralName))
return false;
if (!_entityContextPerEntityName.TryGetValue(relatedPluralName, out var relatedContext))
return false;
if (!TryParseKey(relatedPluralName, property.NavigationKey, out var navigationParsedKey))
return false;
query = query.Where($"{relatedContext.KeyName} == @0", navigationParsedKey);
previousAggregateRoot = relatedPluralName;
previousKeyName = relatedContext.KeyName;
}
return query.Select($"{previousKeyName}").Any();
}
private bool TryParseKey(string entityName, string key, out Nox.Types.INoxType parsedKey)
{
parsedKey = null;
if (entityName.Equals("TestEntities", StringComparison.OrdinalIgnoreCase))
{
if (!System.Int32.TryParse(key, out var value)) return false;
parsedKey = TestEntityMetadata.CreateId(value);
return true;
}
return false;
}
},
SyntaxTree = // Generated
using MediatR;
using Microsoft.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
using Nox.Application.Commands;
using Nox.Application.Services;
using Nox.Domain;
using TestIntegrationSolution.Application.Dto;
using TestIntegrationSolution.Domain;
namespace TestIntegrationSolution.Application.Services;
internal partial class RelationshipChainValidator : RelationshipChainValidatorBase
{
public RelationshipChainValidator(IRepository repository): base(repository)
{
}
}
internal abstract class RelationshipChainValidatorBase: IRelationshipChainValidator
{
private readonly Dictionary<string, (IQueryable Query, string KeyName)> _entityContextPerEntityName;
private readonly Dictionary<string, string> _navigationNameToEntityPluralName;
private readonly Dictionary<(string EntityPluralName, string NavigationName), bool> _isSingleRelationship;
protected IRepository Repository { get; }
#region Constructor
public RelationshipChainValidatorBase(IRepository repository)
{
Repository = repository;
_entityContextPerEntityName = new(StringComparer.OrdinalIgnoreCase)
{
{ "TestEntities", (Repository.Query<TestIntegrationSolution.Domain.TestEntity>(), "Id") }
};
_navigationNameToEntityPluralName = new(StringComparer.OrdinalIgnoreCase)
{
};
_isSingleRelationship = new()
{
};
}
#endregion Constructor
public virtual bool IsValid(RelationshipChain relationshipChain)
{
if (!_entityContextPerEntityName.TryGetValue(relationshipChain.EntityName, out var context))
return false;
if (!TryParseKey(relationshipChain.EntityName, relationshipChain.EntityKey, out var aggregateParsedKey))
return false;
var query = context.Query.Where($"{context.KeyName} == @0", aggregateParsedKey);
var previousAggregateRoot = relationshipChain.EntityName;
var previousKeyName = context.KeyName;
foreach (var property in relationshipChain.SortedNavigationProperties)
{
if (!_isSingleRelationship.TryGetValue((previousAggregateRoot, property.NavigationName), out var isSingle))
return false;
query = query.Select($"new ({previousKeyName}, {property.NavigationName})");
if (isSingle)
query = query.Select($"{property.NavigationName}");
else
query = query.SelectMany($"{property.NavigationName}");
if (!_navigationNameToEntityPluralName.TryGetValue(property.NavigationName, out var relatedPluralName))
return false;
if (!_entityContextPerEntityName.TryGetValue(relatedPluralName, out var relatedContext))
return false;
if (!TryParseKey(relatedPluralName, property.NavigationKey, out var navigationParsedKey))
return false;
query = query.Where($"{relatedContext.KeyName} == @0", navigationParsedKey);
previousAggregateRoot = relatedPluralName;
previousKeyName = relatedContext.KeyName;
}
return query.Select($"{previousKeyName}").Any();
}
private bool TryParseKey(string entityName, string key, out Nox.Types.INoxType parsedKey)
{
parsedKey = null;
if (entityName.Equals("TestEntities", StringComparison.OrdinalIgnoreCase))
{
if (!System.Int32.TryParse(key, out var value)) return false;
parsedKey = TestEntityMetadata.CreateId(value);
return true;
}
return false;
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Queries/GetTestEntityByIdQuery.g.cs",
SourceText = // Generated
#nullable enable
using MediatR;
using Microsoft.EntityFrameworkCore;
using Nox.Application.Queries;
using Nox.Application.Repositories;
using TestIntegrationSolution.Application.Dto;
namespace TestIntegrationSolution.Application.Queries;
public partial record GetTestEntityByIdQuery(System.Int32 keyId) : IRequest <IQueryable<TestEntityDto>>;
internal partial class GetTestEntityByIdQueryHandler:GetTestEntityByIdQueryHandlerBase
{
public GetTestEntityByIdQueryHandler(IReadOnlyRepository readOnlyRepository): base(readOnlyRepository){}
}
internal abstract class GetTestEntityByIdQueryHandlerBase: QueryBase<IQueryable<TestEntityDto>>, IRequestHandler<GetTestEntityByIdQuery, IQueryable<TestEntityDto>>
{
public GetTestEntityByIdQueryHandlerBase(IReadOnlyRepository readOnlyRepository)
{
ReadOnlyRepository = readOnlyRepository;
}
public IReadOnlyRepository ReadOnlyRepository { get; }
public virtual Task<IQueryable<TestEntityDto>> Handle(GetTestEntityByIdQuery request, CancellationToken cancellationToken)
{
var query = ReadOnlyRepository.Query<TestEntityDto>()
.Where(r =>
r.Id.Equals(request.keyId));
return Task.FromResult(OnResponse(query));
}
},
SyntaxTree = // Generated
#nullable enable
using MediatR;
using Microsoft.EntityFrameworkCore;
using Nox.Application.Queries;
using Nox.Application.Repositories;
using TestIntegrationSolution.Application.Dto;
namespace TestIntegrationSolution.Application.Queries;
public partial record GetTestEntityByIdQuery(System.Int32 keyId) : IRequest <IQueryable<TestEntityDto>>;
internal partial class GetTestEntityByIdQueryHandler:GetTestEntityByIdQueryHandlerBase
{
public GetTestEntityByIdQueryHandler(IReadOnlyRepository readOnlyRepository): base(readOnlyRepository){}
}
internal abstract class GetTestEntityByIdQueryHandlerBase: QueryBase<IQueryable<TestEntityDto>>, IRequestHandler<GetTestEntityByIdQuery, IQueryable<TestEntityDto>>
{
public GetTestEntityByIdQueryHandlerBase(IReadOnlyRepository readOnlyRepository)
{
ReadOnlyRepository = readOnlyRepository;
}
public IReadOnlyRepository ReadOnlyRepository { get; }
public virtual Task<IQueryable<TestEntityDto>> Handle(GetTestEntityByIdQuery request, CancellationToken cancellationToken)
{
var query = ReadOnlyRepository.Query<TestEntityDto>()
.Where(r =>
r.Id.Equals(request.keyId));
return Task.FromResult(OnResponse(query));
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Queries/GetTestEntitiesQuery.g.cs",
SourceText = // Generated
#nullable enable
using MediatR;
using Microsoft.EntityFrameworkCore;
using Nox.Application.Queries;
using Nox.Application.Repositories;
using TestIntegrationSolution.Application.Dto;
namespace TestIntegrationSolution.Application.Queries;
public partial record GetTestEntitiesQuery() : IRequest<IQueryable<TestEntityDto>>;
internal partial class GetTestEntitiesQueryHandler: GetTestEntitiesQueryHandlerBase
{
public GetTestEntitiesQueryHandler(IReadOnlyRepository readOnlyRepository): base(readOnlyRepository){}
}
internal abstract class GetTestEntitiesQueryHandlerBase : QueryBase<IQueryable<TestEntityDto>>, IRequestHandler<GetTestEntitiesQuery, IQueryable<TestEntityDto>>
{
public GetTestEntitiesQueryHandlerBase(IReadOnlyRepository readOnlyRepository)
{
ReadOnlyRepository = readOnlyRepository;
}
public IReadOnlyRepository ReadOnlyRepository { get; }
public virtual Task<IQueryable<TestEntityDto>> Handle(GetTestEntitiesQuery request, CancellationToken cancellationToken)
{
var query = ReadOnlyRepository.Query<TestEntityDto>();
return Task.FromResult(OnResponse(query));
}
},
SyntaxTree = // Generated
#nullable enable
using MediatR;
using Microsoft.EntityFrameworkCore;
using Nox.Application.Queries;
using Nox.Application.Repositories;
using TestIntegrationSolution.Application.Dto;
namespace TestIntegrationSolution.Application.Queries;
public partial record GetTestEntitiesQuery() : IRequest<IQueryable<TestEntityDto>>;
internal partial class GetTestEntitiesQueryHandler: GetTestEntitiesQueryHandlerBase
{
public GetTestEntitiesQueryHandler(IReadOnlyRepository readOnlyRepository): base(readOnlyRepository){}
}
internal abstract class GetTestEntitiesQueryHandlerBase : QueryBase<IQueryable<TestEntityDto>>, IRequestHandler<GetTestEntitiesQuery, IQueryable<TestEntityDto>>
{
public GetTestEntitiesQueryHandlerBase(IReadOnlyRepository readOnlyRepository)
{
ReadOnlyRepository = readOnlyRepository;
}
public IReadOnlyRepository ReadOnlyRepository { get; }
public virtual Task<IQueryable<TestEntityDto>> Handle(GetTestEntitiesQuery request, CancellationToken cancellationToken)
{
var query = ReadOnlyRepository.Query<TestEntityDto>();
return Task.FromResult(OnResponse(query));
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Integration.EtlEvents/TestIntegrationRecordCreatedDto.g.cs",
SourceText = //Generated
#nullable enable
using TestIntegrationSolution.Application.Dto;
using Nox.Integration.Abstractions.Interfaces;
namespace TestIntegrationSolution.Application.Integrations;
public class TestIntegrationRecordCreatedDto: TestEntityCreateDto, IEtlEventDto
{
},
SyntaxTree = //Generated
#nullable enable
using TestIntegrationSolution.Application.Dto;
using Nox.Integration.Abstractions.Interfaces;
namespace TestIntegrationSolution.Application.Integrations;
public class TestIntegrationRecordCreatedDto: TestEntityCreateDto, IEtlEventDto
{
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Integration.EtlEvents/TestIntegrationRecordCreatedEvent.g.cs",
SourceText = //Generated
#nullable enable
using MediatR;
using Nox.Integration.Abstractions.Interfaces;
using Nox.Integration.Abstractions.Models;
namespace TestIntegrationSolution.Application.Integrations;
public class TestIntegrationRecordCreatedEvent: EtlRecordCreatedEvent<IEtlEventDto>, INotification
{
public TestIntegrationRecordCreatedEvent(TestIntegrationRecordCreatedDto dto)
{
IntegrationName = "TestIntegration";
SetDto(dto);
}
},
SyntaxTree = //Generated
#nullable enable
using MediatR;
using Nox.Integration.Abstractions.Interfaces;
using Nox.Integration.Abstractions.Models;
namespace TestIntegrationSolution.Application.Integrations;
public class TestIntegrationRecordCreatedEvent: EtlRecordCreatedEvent<IEtlEventDto>, INotification
{
public TestIntegrationRecordCreatedEvent(TestIntegrationRecordCreatedDto dto)
{
IntegrationName = "TestIntegration";
SetDto(dto);
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Integration.EtlEvents/TestIntegrationRecordUpdatedDto.g.cs",
SourceText = //Generated
#nullable enable
using TestIntegrationSolution.Application.Dto;
using Nox.Integration.Abstractions.Interfaces;
namespace TestIntegrationSolution.Application.Integrations;
public class TestIntegrationRecordUpdatedDto: TestEntityUpdateDto, IEtlEventDto
{
},
SyntaxTree = //Generated
#nullable enable
using TestIntegrationSolution.Application.Dto;
using Nox.Integration.Abstractions.Interfaces;
namespace TestIntegrationSolution.Application.Integrations;
public class TestIntegrationRecordUpdatedDto: TestEntityUpdateDto, IEtlEventDto
{
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Integration.EtlEvents/TestIntegrationRecordUpdatedEvent.g.cs",
SourceText = //Generated
#nullable enable
using MediatR;
using Nox.Integration.Abstractions.Interfaces;
using Nox.Integration.Abstractions.Models;
namespace TestIntegrationSolution.Application.Integrations;
public class TestIntegrationRecordUpdatedEvent: EtlRecordUpdatedEvent<IEtlEventDto>, INotification
{
public TestIntegrationRecordUpdatedEvent(TestIntegrationRecordUpdatedDto dto)
{
IntegrationName = "TestIntegration";
SetDto(dto);
}
},
SyntaxTree = //Generated
#nullable enable
using MediatR;
using Nox.Integration.Abstractions.Interfaces;
using Nox.Integration.Abstractions.Models;
namespace TestIntegrationSolution.Application.Integrations;
public class TestIntegrationRecordUpdatedEvent: EtlRecordUpdatedEvent<IEtlEventDto>, INotification
{
public TestIntegrationRecordUpdatedEvent(TestIntegrationRecordUpdatedDto dto)
{
IntegrationName = "TestIntegration";
SetDto(dto);
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Integration.EtlEvents/TestIntegrationExecuteCompletedEvent.g.cs",
SourceText = //Generated
#nullable enable
using MediatR;
using Nox.Integration.Abstractions.Models;
namespace TestIntegrationSolution.Application.Integrations;
public class TestIntegrationExecuteCompletedEvent: EtlExecuteCompletedEvent, INotification
{
public TestIntegrationExecuteCompletedEvent(EtlExecuteCompletedDto dto)
{
IntegrationName = "TestIntegration";
}
},
SyntaxTree = //Generated
#nullable enable
using MediatR;
using Nox.Integration.Abstractions.Models;
namespace TestIntegrationSolution.Application.Integrations;
public class TestIntegrationExecuteCompletedEvent: EtlExecuteCompletedEvent, INotification
{
public TestIntegrationExecuteCompletedEvent(EtlExecuteCompletedDto dto)
{
IntegrationName = "TestIntegration";
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Integration.Jobs/TestIntegrationJob.g.cs",
SourceText = // Generated
#nullable enable
using Nox.Application.Jobs;
using Nox.Integration.Abstractions.Interfaces;
namespace TestIntegrationSolution.Application.Integration.Jobs;
[NoxJob("TestIntegrationJob", "0 2 * * *")]
public class TestIntegrationJob: JobBase
{
private readonly INoxIntegrationContext _context;
public TestIntegrationJob(
ILogger<TestIntegrationJob> logger,
INoxIntegrationContext context) : base(logger)
{
_context = context;
}
public override async Task Run()
{
await _context.ExecuteIntegrationAsync("TestIntegration");
}
},
SyntaxTree = // Generated
#nullable enable
using Nox.Application.Jobs;
using Nox.Integration.Abstractions.Interfaces;
namespace TestIntegrationSolution.Application.Integration.Jobs;
[NoxJob("TestIntegrationJob", "0 2 * * *")]
public class TestIntegrationJob: JobBase
{
private readonly INoxIntegrationContext _context;
public TestIntegrationJob(
ILogger<TestIntegrationJob> logger,
INoxIntegrationContext context) : base(logger)
{
_context = context;
}
public override async Task Run()
{
await _context.ExecuteIntegrationAsync("TestIntegration");
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Integration.Transform/TestIntegrationSourceDto.g.cs",
SourceText = // Generated
#nullable enable
using ETLBox.DataFlow;
namespace TestIntegrationSolution.Application.Integration.CustomTransform;
public sealed class TestIntegrationSourceDto
{
public System.Int64 Id { get; set; }
public System.String? Name { get; set; }
},
SyntaxTree = // Generated
#nullable enable
using ETLBox.DataFlow;
namespace TestIntegrationSolution.Application.Integration.CustomTransform;
public sealed class TestIntegrationSourceDto
{
public System.Int64 Id { get; set; }
public System.String? Name { get; set; }
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Integration.Transform/TestIntegrationTargetDto.g.cs",
SourceText = // Generated
#nullable enable
using Nox.Integration.Abstractions.Models;
namespace TestIntegrationSolution.Application.Integration.CustomTransform;
public sealed class TestIntegrationTargetDto: NoxEntityTargetDto
{
public System.Int64 Id { get; set; }
public System.String? Name { get; set; }
},
SyntaxTree = // Generated
#nullable enable
using Nox.Integration.Abstractions.Models;
namespace TestIntegrationSolution.Application.Integration.CustomTransform;
public sealed class TestIntegrationTargetDto: NoxEntityTargetDto
{
public System.Int64 Id { get; set; }
public System.String? Name { get; set; }
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Integration.Transform/TestIntegrationTransformBase.g.cs",
SourceText = // Generated
#nullable enable
using System.Globalization;
using CryptocashIntegration.Application.Integration.CustomTransform;
using Nox.Integration.Abstractions.Interfaces;
using AutoMapper;
using Nox.Solution;
namespace TestIntegrationSolution.Application.Integration.CustomTransform;
public abstract class TestIntegrationTransformBase: INoxTransform<TestIntegrationSourceDto, TestIntegrationTargetDto>
{
private readonly IMapper _mapper;
protected TestIntegrationTransformBase()
{
_mapper = new MapperConfiguration(cfg =>
{
cfg.CreateMap<TestIntegrationSourceDto, TestIntegrationTargetDto>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name));
}).CreateMapper();
}
public virtual TestIntegrationTargetDto Invoke(TestIntegrationSourceDto source)
{
return _mapper.Map<TestIntegrationSourceDto, TestIntegrationTargetDto>(source);
}
public string IntegrationName => "TestIntegration";
public Type SourceType => typeof(TestIntegrationSourceDto);
public Type TargetType => typeof(TestIntegrationTargetDto);
},
SyntaxTree = // Generated
#nullable enable
using System.Globalization;
using CryptocashIntegration.Application.Integration.CustomTransform;
using Nox.Integration.Abstractions.Interfaces;
using AutoMapper;
using Nox.Solution;
namespace TestIntegrationSolution.Application.Integration.CustomTransform;
public abstract class TestIntegrationTransformBase: INoxTransform<TestIntegrationSourceDto, TestIntegrationTargetDto>
{
private readonly IMapper _mapper;
protected TestIntegrationTransformBase()
{
_mapper = new MapperConfiguration(cfg =>
{
cfg.CreateMap<TestIntegrationSourceDto, TestIntegrationTargetDto>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name));
}).CreateMapper();
}
public virtual TestIntegrationTargetDto Invoke(TestIntegrationSourceDto source)
{
return _mapper.Map<TestIntegrationSourceDto, TestIntegrationTargetDto>(source);
}
public string IntegrationName => "TestIntegration";
public Type SourceType => typeof(TestIntegrationSourceDto);
public Type TargetType => typeof(TestIntegrationTargetDto);
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Factories/TestEntityFactory.g.cs",
SourceText =
// Generated
#nullable enable
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using MediatR;
using Nox.Abstractions;
using Nox.Solution;
using Nox.Domain;
using Nox.Application.Factories;
using Nox.Types;
using Nox.Application;
using Nox.Extensions;
using Nox.Exceptions;
using TestIntegrationSolution.Application.Dto;
using Dto = TestIntegrationSolution.Application.Dto;
using TestIntegrationSolution.Domain;
using TestEntityEntity = TestIntegrationSolution.Domain.TestEntity;
namespace TestIntegrationSolution.Application.Factories;
internal partial class TestEntityFactory : TestEntityFactoryBase
{
public TestEntityFactory
(
) : base()
{}
}
internal abstract class TestEntityFactoryBase : IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto>
{
public TestEntityFactoryBase(
)
{
}
public virtual async Task<TestEntityEntity> CreateEntityAsync(TestEntityCreateDto createDto, Nox.Types.CultureCode cultureCode)
{
try
{
var entity = await ToEntityAsync(createDto, cultureCode);
return entity;
}
catch (NoxTypeValidationException ex)
{
throw new CreateUpdateEntityInvalidDataException(ex, nameof(TestEntityEntity));
}
}
public virtual async Task UpdateEntityAsync(TestEntityEntity entity, TestEntityUpdateDto updateDto, Nox.Types.CultureCode cultureCode)
{
try
{
await UpdateEntityInternalAsync(entity, updateDto, cultureCode);
}
catch (NoxTypeValidationException ex)
{
throw new CreateUpdateEntityInvalidDataException(ex, nameof(TestEntityEntity));
}
}
public virtual async Task PartialUpdateEntityAsync(TestEntityEntity entity, Dictionary<string, dynamic> updatedProperties, Nox.Types.CultureCode cultureCode)
{
try
{
PartialUpdateEntityInternal(entity, updatedProperties, cultureCode);
await Task.CompletedTask;
}
catch (NoxTypeValidationException ex)
{
throw new CreateUpdateEntityInvalidDataException(ex, nameof(TestEntityEntity));
}
}
private async Task<TestIntegrationSolution.Domain.TestEntity> ToEntityAsync(TestEntityCreateDto createDto, Nox.Types.CultureCode cultureCode)
{
ExceptionCollector<NoxTypeValidationException> exceptionCollector = new();
var entity = new TestIntegrationSolution.Domain.TestEntity();
exceptionCollector.Collect("Id",() => entity.Id = Dto.TestEntityMetadata.CreateId(createDto.Id.NonNullValue<System.Int32>()));
exceptionCollector.Collect("Name", () => entity.SetIfNotNull(createDto.Name, (entity) => entity.Name =
Dto.TestEntityMetadata.CreateName(createDto.Name.NonNullValue<System.String>())));
CreateUpdateEntityInvalidDataException.ThrowIfAnyNoxTypeValidationException(exceptionCollector.ValidationErrors);
return await Task.FromResult(entity);
}
private async Task UpdateEntityInternalAsync(TestEntityEntity entity, TestEntityUpdateDto updateDto, Nox.Types.CultureCode cultureCode)
{
ExceptionCollector<NoxTypeValidationException> exceptionCollector = new();
exceptionCollector.Collect("Name",() => entity.Name = Dto.TestEntityMetadata.CreateName(updateDto.Name.NonNullValue<System.String>()));
CreateUpdateEntityInvalidDataException.ThrowIfAnyNoxTypeValidationException(exceptionCollector.ValidationErrors);
await Task.CompletedTask;
}
private void PartialUpdateEntityInternal(TestEntityEntity entity, Dictionary<string, dynamic> updatedProperties, Nox.Types.CultureCode cultureCode)
{
ExceptionCollector<NoxTypeValidationException> exceptionCollector = new();
if (updatedProperties.TryGetValue("Name", out var NameUpdateValue))
{
ArgumentNullException.ThrowIfNull(NameUpdateValue, "Attribute 'Name' can't be null.");
{
exceptionCollector.Collect("Name",() =>entity.Name = Dto.TestEntityMetadata.CreateName(NameUpdateValue));
}
}
CreateUpdateEntityInvalidDataException.ThrowIfAnyNoxTypeValidationException(exceptionCollector.ValidationErrors);
}
},
SyntaxTree =
// Generated
#nullable enable
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using MediatR;
using Nox.Abstractions;
using Nox.Solution;
using Nox.Domain;
using Nox.Application.Factories;
using Nox.Types;
using Nox.Application;
using Nox.Extensions;
using Nox.Exceptions;
using TestIntegrationSolution.Application.Dto;
using Dto = TestIntegrationSolution.Application.Dto;
using TestIntegrationSolution.Domain;
using TestEntityEntity = TestIntegrationSolution.Domain.TestEntity;
namespace TestIntegrationSolution.Application.Factories;
internal partial class TestEntityFactory : TestEntityFactoryBase
{
public TestEntityFactory
(
) : base()
{}
}
internal abstract class TestEntityFactoryBase : IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto>
{
public TestEntityFactoryBase(
)
{
}
public virtual async Task<TestEntityEntity> CreateEntityAsync(TestEntityCreateDto createDto, Nox.Types.CultureCode cultureCode)
{
try
{
var entity = await ToEntityAsync(createDto, cultureCode);
return entity;
}
catch (NoxTypeValidationException ex)
{
throw new CreateUpdateEntityInvalidDataException(ex, nameof(TestEntityEntity));
}
}
public virtual async Task UpdateEntityAsync(TestEntityEntity entity, TestEntityUpdateDto updateDto, Nox.Types.CultureCode cultureCode)
{
try
{
await UpdateEntityInternalAsync(entity, updateDto, cultureCode);
}
catch (NoxTypeValidationException ex)
{
throw new CreateUpdateEntityInvalidDataException(ex, nameof(TestEntityEntity));
}
}
public virtual async Task PartialUpdateEntityAsync(TestEntityEntity entity, Dictionary<string, dynamic> updatedProperties, Nox.Types.CultureCode cultureCode)
{
try
{
PartialUpdateEntityInternal(entity, updatedProperties, cultureCode);
await Task.CompletedTask;
}
catch (NoxTypeValidationException ex)
{
throw new CreateUpdateEntityInvalidDataException(ex, nameof(TestEntityEntity));
}
}
private async Task<TestIntegrationSolution.Domain.TestEntity> ToEntityAsync(TestEntityCreateDto createDto, Nox.Types.CultureCode cultureCode)
{
ExceptionCollector<NoxTypeValidationException> exceptionCollector = new();
var entity = new TestIntegrationSolution.Domain.TestEntity();
exceptionCollector.Collect("Id",() => entity.Id = Dto.TestEntityMetadata.CreateId(createDto.Id.NonNullValue<System.Int32>()));
exceptionCollector.Collect("Name", () => entity.SetIfNotNull(createDto.Name, (entity) => entity.Name =
Dto.TestEntityMetadata.CreateName(createDto.Name.NonNullValue<System.String>())));
CreateUpdateEntityInvalidDataException.ThrowIfAnyNoxTypeValidationException(exceptionCollector.ValidationErrors);
return await Task.FromResult(entity);
}
private async Task UpdateEntityInternalAsync(TestEntityEntity entity, TestEntityUpdateDto updateDto, Nox.Types.CultureCode cultureCode)
{
ExceptionCollector<NoxTypeValidationException> exceptionCollector = new();
exceptionCollector.Collect("Name",() => entity.Name = Dto.TestEntityMetadata.CreateName(updateDto.Name.NonNullValue<System.String>()));
CreateUpdateEntityInvalidDataException.ThrowIfAnyNoxTypeValidationException(exceptionCollector.ValidationErrors);
await Task.CompletedTask;
}
private void PartialUpdateEntityInternal(TestEntityEntity entity, Dictionary<string, dynamic> updatedProperties, Nox.Types.CultureCode cultureCode)
{
ExceptionCollector<NoxTypeValidationException> exceptionCollector = new();
if (updatedProperties.TryGetValue("Name", out var NameUpdateValue))
{
ArgumentNullException.ThrowIfNull(NameUpdateValue, "Attribute 'Name' can't be null.");
{
exceptionCollector.Collect("Name",() =>entity.Name = Dto.TestEntityMetadata.CreateName(NameUpdateValue));
}
}
CreateUpdateEntityInvalidDataException.ThrowIfAnyNoxTypeValidationException(exceptionCollector.ValidationErrors);
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Extensions/TestEntityExtensions.g.cs",
SourceText = // Generated
#nullable enable
using System;
using System.Linq;
using Nox.Extensions;
namespace TestIntegrationSolution.Application.Dto;
internal static class TestEntityExtensions
{
public static TestEntityDto ToDto(this TestIntegrationSolution.Domain.TestEntity entity)
{
var dto = new TestEntityDto();
dto.SetIfNotNull(entity?.Id, (dto) => dto.Id = entity!.Id.Value);
dto.SetIfNotNull(entity?.Name, (dto) => dto.Name =entity!.Name!.Value);
return dto;
}
},
SyntaxTree = // Generated
#nullable enable
using System;
using System.Linq;
using Nox.Extensions;
namespace TestIntegrationSolution.Application.Dto;
internal static class TestEntityExtensions
{
public static TestEntityDto ToDto(this TestIntegrationSolution.Domain.TestEntity entity)
{
var dto = new TestEntityDto();
dto.SetIfNotNull(entity?.Id, (dto) => dto.Id = entity!.Id.Value);
dto.SetIfNotNull(entity?.Name, (dto) => dto.Name =entity!.Name!.Value);
return dto;
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Extensions/CompoundNoxTypesExtensions.g.cs",
SourceText = // Generated
#nullable enable
using Nox.Types;
namespace TestIntegrationSolution.Application.Dto;
internal static class CompoundNoxTypesExtensions
{
public static StreetAddressDto ToDto(this Nox.Types.StreetAddress StreetAddress)
=> new(StreetAddress.StreetNumber!, StreetAddress.AddressLine1!, StreetAddress.AddressLine2!, StreetAddress.AddressLine3!, StreetAddress.Route!, StreetAddress.Locality!, StreetAddress.Neighborhood!, StreetAddress.AdministrativeArea1!, StreetAddress.AdministrativeArea2!, StreetAddress.PostalCode!, StreetAddress.CountryId!);
public static FileDto ToDto(this Nox.Types.File File)
=> new(File.Url!, File.PrettyName!, File.SizeInBytes!);
public static TranslatedTextDto ToDto(this Nox.Types.TranslatedText TranslatedText)
=> new(TranslatedText.CultureCode!, TranslatedText.Phrase!);
public static VatNumberDto ToDto(this Nox.Types.VatNumber VatNumber)
=> new(VatNumber.Number!, VatNumber.CountryCode!);
public static PasswordDto ToDto(this Nox.Types.Password Password)
=> new(Password.HashedPassword!, Password.Salt!);
public static MoneyDto ToDto(this Nox.Types.Money Money)
=> new(Money.Amount!, Money.CurrencyCode!);
public static ImageDto ToDto(this Nox.Types.Image Image)
=> new(Image.Url!, Image.PrettyName!, Image.SizeInBytes!);
public static HashedTextDto ToDto(this Nox.Types.HashedText HashedText)
=> new(HashedText.HashText!, HashedText.Salt!);
public static DateTimeRangeDto ToDto(this Nox.Types.DateTimeRange DateTimeRange)
=> new(DateTimeRange.Start!, DateTimeRange.End!);
public static LatLongDto ToDto(this Nox.Types.LatLong LatLong)
=> new(LatLong.Latitude!, LatLong.Longitude!);
},
SyntaxTree = // Generated
#nullable enable
using Nox.Types;
namespace TestIntegrationSolution.Application.Dto;
internal static class CompoundNoxTypesExtensions
{
public static StreetAddressDto ToDto(this Nox.Types.StreetAddress StreetAddress)
=> new(StreetAddress.StreetNumber!, StreetAddress.AddressLine1!, StreetAddress.AddressLine2!, StreetAddress.AddressLine3!, StreetAddress.Route!, StreetAddress.Locality!, StreetAddress.Neighborhood!, StreetAddress.AdministrativeArea1!, StreetAddress.AdministrativeArea2!, StreetAddress.PostalCode!, StreetAddress.CountryId!);
public static FileDto ToDto(this Nox.Types.File File)
=> new(File.Url!, File.PrettyName!, File.SizeInBytes!);
public static TranslatedTextDto ToDto(this Nox.Types.TranslatedText TranslatedText)
=> new(TranslatedText.CultureCode!, TranslatedText.Phrase!);
public static VatNumberDto ToDto(this Nox.Types.VatNumber VatNumber)
=> new(VatNumber.Number!, VatNumber.CountryCode!);
public static PasswordDto ToDto(this Nox.Types.Password Password)
=> new(Password.HashedPassword!, Password.Salt!);
public static MoneyDto ToDto(this Nox.Types.Money Money)
=> new(Money.Amount!, Money.CurrencyCode!);
public static ImageDto ToDto(this Nox.Types.Image Image)
=> new(Image.Url!, Image.PrettyName!, Image.SizeInBytes!);
public static HashedTextDto ToDto(this Nox.Types.HashedText HashedText)
=> new(HashedText.HashText!, HashedText.Salt!);
public static DateTimeRangeDto ToDto(this Nox.Types.DateTimeRange DateTimeRange)
=> new(DateTimeRange.Start!, DateTimeRange.End!);
public static LatLongDto ToDto(this Nox.Types.LatLong LatLong)
=> new(LatLong.Latitude!, LatLong.Longitude!);
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Commands/CreateTestEntityCommand.g.cs",
SourceText = // Generated
#nullable enable
using MediatR;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using FluentValidation;
using Microsoft.Extensions.Logging;
using Nox.Abstractions;
using Nox.Application;
using Nox.Application.Commands;
using Nox.Exceptions;
using Nox.Extensions;
using Nox.Application.Factories;
using Nox.Solution;
using Nox.Domain;
using TestIntegrationSolution.Domain;
using TestIntegrationSolution.Application.Dto;
using Dto = TestIntegrationSolution.Application.Dto;
using TestEntityEntity = TestIntegrationSolution.Domain.TestEntity;
namespace TestIntegrationSolution.Application.Commands;
public partial record CreateTestEntityCommand(TestEntityCreateDto EntityDto, Nox.Types.CultureCode CultureCode) : IRequest<TestEntityKeyDto>;
internal partial class CreateTestEntityCommandHandler : CreateTestEntityCommandHandlerBase
{
public CreateTestEntityCommandHandler(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(repository, noxSolution,entityFactory)
{
}
}
internal abstract class CreateTestEntityCommandHandlerBase : CommandBase<CreateTestEntityCommand,TestEntityEntity>, IRequestHandler <CreateTestEntityCommand, TestEntityKeyDto>
{
protected readonly IRepository Repository;
protected readonly IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> EntityFactory;
protected CreateTestEntityCommandHandlerBase(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(noxSolution)
{
Repository = repository;
EntityFactory = entityFactory;
}
public virtual async Task<TestEntityKeyDto> Handle(CreateTestEntityCommand request, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
await OnExecutingAsync(request);
var entityToCreate = await EntityFactory.CreateEntityAsync(request.EntityDto, request.CultureCode);
await OnCompletedAsync(request, entityToCreate);
await Repository.AddAsync<TestIntegrationSolution.Domain.TestEntity>(entityToCreate);
await Repository.SaveChangesAsync();
return new TestEntityKeyDto(entityToCreate.Id.Value);
}
},
SyntaxTree = // Generated
#nullable enable
using MediatR;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using FluentValidation;
using Microsoft.Extensions.Logging;
using Nox.Abstractions;
using Nox.Application;
using Nox.Application.Commands;
using Nox.Exceptions;
using Nox.Extensions;
using Nox.Application.Factories;
using Nox.Solution;
using Nox.Domain;
using TestIntegrationSolution.Domain;
using TestIntegrationSolution.Application.Dto;
using Dto = TestIntegrationSolution.Application.Dto;
using TestEntityEntity = TestIntegrationSolution.Domain.TestEntity;
namespace TestIntegrationSolution.Application.Commands;
public partial record CreateTestEntityCommand(TestEntityCreateDto EntityDto, Nox.Types.CultureCode CultureCode) : IRequest<TestEntityKeyDto>;
internal partial class CreateTestEntityCommandHandler : CreateTestEntityCommandHandlerBase
{
public CreateTestEntityCommandHandler(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(repository, noxSolution,entityFactory)
{
}
}
internal abstract class CreateTestEntityCommandHandlerBase : CommandBase<CreateTestEntityCommand,TestEntityEntity>, IRequestHandler <CreateTestEntityCommand, TestEntityKeyDto>
{
protected readonly IRepository Repository;
protected readonly IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> EntityFactory;
protected CreateTestEntityCommandHandlerBase(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(noxSolution)
{
Repository = repository;
EntityFactory = entityFactory;
}
public virtual async Task<TestEntityKeyDto> Handle(CreateTestEntityCommand request, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
await OnExecutingAsync(request);
var entityToCreate = await EntityFactory.CreateEntityAsync(request.EntityDto, request.CultureCode);
await OnCompletedAsync(request, entityToCreate);
await Repository.AddAsync<TestIntegrationSolution.Domain.TestEntity>(entityToCreate);
await Repository.SaveChangesAsync();
return new TestEntityKeyDto(entityToCreate.Id.Value);
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Commands/DeleteTestEntityByIdCommand.g.cs",
SourceText = // Generated
#nullable enable
using MediatR;
using Microsoft.EntityFrameworkCore;
using Nox.Application.Commands;
using Nox.Solution;
using Nox.Types;
using Nox.Domain;
using Nox.Exceptions;
using TestIntegrationSolution.Domain;
using TestIntegrationSolution.Application.Dto;
using Dto = TestIntegrationSolution.Application.Dto;
using TestEntityEntity = TestIntegrationSolution.Domain.TestEntity;
namespace TestIntegrationSolution.Application.Commands;
public partial record DeleteTestEntityByIdCommand(IEnumerable<TestEntityKeyDto> KeyDtos, System.Guid? Etag) : IRequest<bool>;
internal partial class DeleteTestEntityByIdCommandHandler : DeleteTestEntityByIdCommandHandlerBase
{
public DeleteTestEntityByIdCommandHandler(
IRepository repository,
NoxSolution noxSolution) : base(repository, noxSolution)
{
}
}
internal abstract class DeleteTestEntityByIdCommandHandlerBase : CommandCollectionBase<DeleteTestEntityByIdCommand, TestEntityEntity>, IRequestHandler<DeleteTestEntityByIdCommand, bool>
{
public IRepository Repository { get; }
public DeleteTestEntityByIdCommandHandlerBase(
IRepository repository,
NoxSolution noxSolution) : base(noxSolution)
{
Repository = repository;
}
public virtual async Task<bool> Handle(DeleteTestEntityByIdCommand request, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
await OnExecutingAsync(request);
var keys = request.KeyDtos.ToArray();
var entities = new List<TestEntityEntity>(keys.Length);
foreach(var keyDto in keys)
{
var keyId = Dto.TestEntityMetadata.CreateId(keyDto.keyId);
var entity = await Repository.FindAsync<TestEntityEntity>(keyId);
if (entity == null || entity.IsDeleted == true)
{
throw new EntityNotFoundException("TestEntity", $"{keyId.ToString()}");
}
entity.Etag = request.Etag.HasValue ? request.Etag.Value : System.Guid.Empty;
entities.Add(entity);
}
Repository.DeleteRange<TestEntityEntity>(entities);
await OnCompletedAsync(request, entities);
await Repository.SaveChangesAsync(cancellationToken);
return true;
}
},
SyntaxTree = // Generated
#nullable enable
using MediatR;
using Microsoft.EntityFrameworkCore;
using Nox.Application.Commands;
using Nox.Solution;
using Nox.Types;
using Nox.Domain;
using Nox.Exceptions;
using TestIntegrationSolution.Domain;
using TestIntegrationSolution.Application.Dto;
using Dto = TestIntegrationSolution.Application.Dto;
using TestEntityEntity = TestIntegrationSolution.Domain.TestEntity;
namespace TestIntegrationSolution.Application.Commands;
public partial record DeleteTestEntityByIdCommand(IEnumerable<TestEntityKeyDto> KeyDtos, System.Guid? Etag) : IRequest<bool>;
internal partial class DeleteTestEntityByIdCommandHandler : DeleteTestEntityByIdCommandHandlerBase
{
public DeleteTestEntityByIdCommandHandler(
IRepository repository,
NoxSolution noxSolution) : base(repository, noxSolution)
{
}
}
internal abstract class DeleteTestEntityByIdCommandHandlerBase : CommandCollectionBase<DeleteTestEntityByIdCommand, TestEntityEntity>, IRequestHandler<DeleteTestEntityByIdCommand, bool>
{
public IRepository Repository { get; }
public DeleteTestEntityByIdCommandHandlerBase(
IRepository repository,
NoxSolution noxSolution) : base(noxSolution)
{
Repository = repository;
}
public virtual async Task<bool> Handle(DeleteTestEntityByIdCommand request, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
await OnExecutingAsync(request);
var keys = request.KeyDtos.ToArray();
var entities = new List<TestEntityEntity>(keys.Length);
foreach(var keyDto in keys)
{
var keyId = Dto.TestEntityMetadata.CreateId(keyDto.keyId);
var entity = await Repository.FindAsync<TestEntityEntity>(keyId);
if (entity == null || entity.IsDeleted == true)
{
throw new EntityNotFoundException("TestEntity", $"{keyId.ToString()}");
}
entity.Etag = request.Etag.HasValue ? request.Etag.Value : System.Guid.Empty;
entities.Add(entity);
}
Repository.DeleteRange<TestEntityEntity>(entities);
await OnCompletedAsync(request, entities);
await Repository.SaveChangesAsync(cancellationToken);
return true;
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Commands/PartialUpdateTestEntityCommand.g.cs",
SourceText = // Generated
#nullable enable
using MediatR;
using Microsoft.EntityFrameworkCore;
using Nox.Application.Commands;
using Nox.Application.Factories;
using Nox.Solution;
using Nox.Domain;
using Nox.Types;
using Nox.Exceptions;
using TestIntegrationSolution.Domain;
using TestIntegrationSolution.Application.Dto;
using Dto = TestIntegrationSolution.Application.Dto;
using TestEntityEntity = TestIntegrationSolution.Domain.TestEntity;
namespace TestIntegrationSolution.Application.Commands;
public partial record PartialUpdateTestEntityCommand(System.Int32 keyId, Dictionary<string, dynamic> UpdatedProperties, Nox.Types.CultureCode CultureCode, System.Guid? Etag) : IRequest <TestEntityKeyDto>;
internal partial class PartialUpdateTestEntityCommandHandler : PartialUpdateTestEntityCommandHandlerBase
{
public PartialUpdateTestEntityCommandHandler(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(repository,noxSolution, entityFactory)
{
}
}
internal abstract class PartialUpdateTestEntityCommandHandlerBase : CommandBase<PartialUpdateTestEntityCommand, TestEntityEntity>, IRequestHandler<PartialUpdateTestEntityCommand, TestEntityKeyDto>
{
public IRepository Repository { get; }
public IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> EntityFactory { get; }
public PartialUpdateTestEntityCommandHandlerBase(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(noxSolution)
{
Repository = repository;
EntityFactory = entityFactory;
}
public virtual async Task<TestEntityKeyDto> Handle(PartialUpdateTestEntityCommand request, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
await OnExecutingAsync(request);
var keyId = Dto.TestEntityMetadata.CreateId(request.keyId);
var entity = await Repository.FindAsync<TestIntegrationSolution.Domain.TestEntity>(keyId);
if (entity == null)
{
throw new EntityNotFoundException("TestEntity", $"{keyId.ToString()}");
}
await EntityFactory.PartialUpdateEntityAsync(entity, request.UpdatedProperties, request.CultureCode);
entity.Etag = request.Etag.HasValue ? request.Etag.Value : System.Guid.Empty;
Repository.Update(entity);
await OnCompletedAsync(request, entity);
await Repository.SaveChangesAsync();
return new TestEntityKeyDto(entity.Id.Value);
}
},
SyntaxTree = // Generated
#nullable enable
using MediatR;
using Microsoft.EntityFrameworkCore;
using Nox.Application.Commands;
using Nox.Application.Factories;
using Nox.Solution;
using Nox.Domain;
using Nox.Types;
using Nox.Exceptions;
using TestIntegrationSolution.Domain;
using TestIntegrationSolution.Application.Dto;
using Dto = TestIntegrationSolution.Application.Dto;
using TestEntityEntity = TestIntegrationSolution.Domain.TestEntity;
namespace TestIntegrationSolution.Application.Commands;
public partial record PartialUpdateTestEntityCommand(System.Int32 keyId, Dictionary<string, dynamic> UpdatedProperties, Nox.Types.CultureCode CultureCode, System.Guid? Etag) : IRequest <TestEntityKeyDto>;
internal partial class PartialUpdateTestEntityCommandHandler : PartialUpdateTestEntityCommandHandlerBase
{
public PartialUpdateTestEntityCommandHandler(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(repository,noxSolution, entityFactory)
{
}
}
internal abstract class PartialUpdateTestEntityCommandHandlerBase : CommandBase<PartialUpdateTestEntityCommand, TestEntityEntity>, IRequestHandler<PartialUpdateTestEntityCommand, TestEntityKeyDto>
{
public IRepository Repository { get; }
public IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> EntityFactory { get; }
public PartialUpdateTestEntityCommandHandlerBase(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(noxSolution)
{
Repository = repository;
EntityFactory = entityFactory;
}
public virtual async Task<TestEntityKeyDto> Handle(PartialUpdateTestEntityCommand request, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
await OnExecutingAsync(request);
var keyId = Dto.TestEntityMetadata.CreateId(request.keyId);
var entity = await Repository.FindAsync<TestIntegrationSolution.Domain.TestEntity>(keyId);
if (entity == null)
{
throw new EntityNotFoundException("TestEntity", $"{keyId.ToString()}");
}
await EntityFactory.PartialUpdateEntityAsync(entity, request.UpdatedProperties, request.CultureCode);
entity.Etag = request.Etag.HasValue ? request.Etag.Value : System.Guid.Empty;
Repository.Update(entity);
await OnCompletedAsync(request, entity);
await Repository.SaveChangesAsync();
return new TestEntityKeyDto(entity.Id.Value);
}
}
},
Microsoft.CodeAnalysis.GeneratedSourceResult
{
HintName = "Application.Commands/UpdateTestEntityCommand.g.cs",
SourceText =
// Generated
#nullable enable
using MediatR;
using Microsoft.EntityFrameworkCore;
using FluentValidation;
using Nox.Application.Commands;
using Nox.Domain;
using Nox.Solution;
using Nox.Types;
using Nox.Application.Factories;
using Nox.Exceptions;
using Nox.Extensions;
using TestIntegrationSolution.Domain;
using TestIntegrationSolution.Application.Dto;
using Dto = TestIntegrationSolution.Application.Dto;
using TestEntityEntity = TestIntegrationSolution.Domain.TestEntity;
namespace TestIntegrationSolution.Application.Commands;
public partial record UpdateTestEntityCommand(System.Int32 keyId, TestEntityUpdateDto EntityDto, Nox.Types.CultureCode CultureCode, System.Guid? Etag) : IRequest<TestEntityKeyDto>;
internal partial class UpdateTestEntityCommandHandler : UpdateTestEntityCommandHandlerBase
{
public UpdateTestEntityCommandHandler(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(repository, noxSolution, entityFactory)
{
}
}
internal abstract class UpdateTestEntityCommandHandlerBase : CommandBase<UpdateTestEntityCommand, TestEntityEntity>, IRequestHandler<UpdateTestEntityCommand, TestEntityKeyDto>
{
protected IRepository Repository { get; }
protected IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> EntityFactory { get; }
protected UpdateTestEntityCommandHandlerBase(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(noxSolution)
{
Repository = repository;
EntityFactory = entityFactory;
}
public virtual async Task<TestEntityKeyDto> Handle(UpdateTestEntityCommand request, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
await OnExecutingAsync(request);
var entity = Repository.Query<TestIntegrationSolution.Domain.TestEntity>()
.Where(x => x.Id == Dto.TestEntityMetadata.CreateId(request.keyId))
.SingleOrDefault();
if (entity == null)
{
throw new EntityNotFoundException("TestEntity", "keyId");
}
await EntityFactory.UpdateEntityAsync(entity, request.EntityDto, request.CultureCode);
entity.Etag = request.Etag ?? System.Guid.Empty;
Repository.Update(entity);
await OnCompletedAsync(request, entity);
await Repository.SaveChangesAsync();
return new TestEntityKeyDto(entity.Id.Value);
}
},
SyntaxTree =
// Generated
#nullable enable
using MediatR;
using Microsoft.EntityFrameworkCore;
using FluentValidation;
using Nox.Application.Commands;
using Nox.Domain;
using Nox.Solution;
using Nox.Types;
using Nox.Application.Factories;
using Nox.Exceptions;
using Nox.Extensions;
using TestIntegrationSolution.Domain;
using TestIntegrationSolution.Application.Dto;
using Dto = TestIntegrationSolution.Application.Dto;
using TestEntityEntity = TestIntegrationSolution.Domain.TestEntity;
namespace TestIntegrationSolution.Application.Commands;
public partial record UpdateTestEntityCommand(System.Int32 keyId, TestEntityUpdateDto EntityDto, Nox.Types.CultureCode CultureCode, System.Guid? Etag) : IRequest<TestEntityKeyDto>;
internal partial class UpdateTestEntityCommandHandler : UpdateTestEntityCommandHandlerBase
{
public UpdateTestEntityCommandHandler(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(repository, noxSolution, entityFactory)
{
}
}
internal abstract class UpdateTestEntityCommandHandlerBase : CommandBase<UpdateTestEntityCommand, TestEntityEntity>, IRequestHandler<UpdateTestEntityCommand, TestEntityKeyDto>
{
protected IRepository Repository { get; }
protected IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> EntityFactory { get; }
protected UpdateTestEntityCommandHandlerBase(
IRepository repository,
NoxSolution noxSolution,
IEntityFactory<TestEntityEntity, TestEntityCreateDto, TestEntityUpdateDto> entityFactory)
: base(noxSolution)
{
Repository = repository;
EntityFactory = entityFactory;
}
public virtual async Task<TestEntityKeyDto> Handle(UpdateTestEntityCommand request, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
await OnExecutingAsync(request);
var entity = Repository.Query<TestIntegrationSolution.Domain.TestEntity>()
.Where(x => x.Id == Dto.TestEntityMetadata.CreateId(request.keyId))
.SingleOrDefault();
if (entity == null)
{
throw new EntityNotFoundException("TestEntity", "keyId");
}
await EntityFactory.UpdateEntityAsync(entity, request.EntityDto, request.CultureCode);
entity.Etag = request.Etag ?? System.Guid.Empty;
Repository.Update(entity);
await OnCompletedAsync(request, entity);
await Repository.SaveChangesAsync();
return new TestEntityKeyDto(entity.Id
|
build (8.x):
src/Nox.Yaml/YamlConfigurationReader.cs#L355
Loops should be simplified using the "Where" LINQ method (https://rules.sonarsource.com/csharp/RSPEC-3267)
|
build (8.x):
src/Nox.Types/Types/VatNumber/VatNumber.cs#L76
Remove the unused private setter 'set_Number'. (https://rules.sonarsource.com/csharp/RSPEC-1144)
|
build (8.x):
src/Nox.Types/Types/VatNumber/VatNumber.cs#L82
Remove the unused private setter 'set_CountryCode'. (https://rules.sonarsource.com/csharp/RSPEC-1144)
|
build (8.x)
Private classes which are not derived in the current assembly should be marked as 'sealed'. (https://rules.sonarsource.com/csharp/RSPEC-3260)
|
build (8.x)
Private classes which are not derived in the current assembly should be marked as 'sealed'. (https://rules.sonarsource.com/csharp/RSPEC-3260)
|
build (8.x)
Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
|
build (8.x)
Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
|
build (8.x)
Private classes which are not derived in the current assembly should be marked as 'sealed'. (https://rules.sonarsource.com/csharp/RSPEC-3260)
|
build (8.x)
Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
|
build (8.x)
Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
|
build (8.x)
Failed test were found and 'fail-on-error' option is set to true
|
build (8.x)
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v3, actions/setup-java@v3, actions/setup-dotnet@v3, actions/cache@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
|
build (8.x):
src/Nox.Yaml/YamlConfigurationReader.cs#L355
Loops should be simplified using the "Where" LINQ method (https://rules.sonarsource.com/csharp/RSPEC-3267)
|
build (8.x):
src/Nox.Types/Types/VatNumber/VatNumber.cs#L76
Remove the unused private setter 'set_Number'. (https://rules.sonarsource.com/csharp/RSPEC-1144)
|
build (8.x):
src/Nox.Types/Types/VatNumber/VatNumber.cs#L82
Remove the unused private setter 'set_CountryCode'. (https://rules.sonarsource.com/csharp/RSPEC-1144)
|
build (8.x)
Private classes which are not derived in the current assembly should be marked as 'sealed'. (https://rules.sonarsource.com/csharp/RSPEC-3260)
|
build (8.x)
Private classes which are not derived in the current assembly should be marked as 'sealed'. (https://rules.sonarsource.com/csharp/RSPEC-3260)
|
build (8.x)
Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
|
build (8.x)
Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
|
build (8.x)
Private classes which are not derived in the current assembly should be marked as 'sealed'. (https://rules.sonarsource.com/csharp/RSPEC-3260)
|
build (8.x)
Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
|
build (8.x)
Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
|
build (8.x)
Test report summary exceeded limit of 65535 bytes and will be trimmed
|