Implementierung von DirectorySearchService für Active Directory-Suchen. Unterstützt Caching und Konfiguration für Suchfunktionalität.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user