Implementierung von DirectorySearchService für Active Directory-Suchen. Unterstützt Caching und Konfiguration für Suchfunktionalität.

This commit is contained in:
Developer 02
2024-03-22 11:05:44 +01:00
parent 6659ac25c8
commit 9644d1653c
119 changed files with 2370 additions and 388 deletions

View File

@@ -21,7 +21,7 @@ namespace DigitalData.Core.Application
protected readonly TCRUDRepository _repository;
protected readonly IMapper _mapper;
protected readonly IKeyTranslationService _translationService;
protected readonly PropertyInfo _keyPropertyInfo;
protected readonly PropertyInfo? _keyPropertyInfo;
/// <summary>
/// Initializes a new instance of the CRUDService class with the specified repository, translation service, and mapper.
@@ -36,8 +36,7 @@ namespace DigitalData.Core.Application
_mapper = mapper;
_keyPropertyInfo = typeof(TEntity).GetProperties()
.FirstOrDefault(prop => Attribute.IsDefined(prop, typeof(KeyAttribute)))
?? throw new InvalidOperationException($"No property with [Key] attribute found on {typeof(TEntity).Name} entity.");
.FirstOrDefault(prop => Attribute.IsDefined(prop, typeof(KeyAttribute)));
}
/// <summary>
@@ -146,7 +145,11 @@ namespace DigitalData.Core.Application
/// <returns>The ID of the entity.</returns>
protected virtual TId KeyValueOf(TEntity entity)
{
object idObj = _keyPropertyInfo.GetValue(entity) ?? throw new InvalidOperationException($"The ID property of {typeof(TEntity).Name} entity cannot be null.");
if(_keyPropertyInfo is null)
throw new InvalidOperationException($"No property with [Key] attribute found on {typeof(TEntity).Name} entity.");
object idObj = _keyPropertyInfo?.GetValue(entity) ?? throw new InvalidOperationException($"The ID property of {typeof(TEntity).Name} entity cannot be null.");
if (idObj is TId id)
return id;
else