diff --git a/Sieve/Attributes/SieveAttribute.cs b/Sieve/Attributes/SieveAttribute.cs index fd85752..19fbb08 100644 --- a/Sieve/Attributes/SieveAttribute.cs +++ b/Sieve/Attributes/SieveAttribute.cs @@ -11,6 +11,8 @@ namespace Sieve.Attributes /// public string Name { get; set; } + public string FullName => Name; + public bool CanSort { get; set; } public bool CanFilter { get; set; } } diff --git a/Sieve/Models/ISievePropertyMetadata.cs b/Sieve/Models/ISievePropertyMetadata.cs index 51b89b8..f12f6d9 100644 --- a/Sieve/Models/ISievePropertyMetadata.cs +++ b/Sieve/Models/ISievePropertyMetadata.cs @@ -3,7 +3,7 @@ public interface ISievePropertyMetadata { string Name { get; set; } - string FullName { get; set; } + string FullName { get; } bool CanFilter { get; set; } bool CanSort { get; set; } } diff --git a/Sieve/Services/SieveProcessor.cs b/Sieve/Services/SieveProcessor.cs index 3d715cf..cf54d31 100644 --- a/Sieve/Services/SieveProcessor.cs +++ b/Sieve/Services/SieveProcessor.cs @@ -359,7 +359,7 @@ namespace Sieve.Services if(property.Item1 == null) { var prop = FindPropertyBySieveAttribute(canSortRequired, canFilterRequired, name, _options.Value.CaseSensitive); - return (prop.Name, prop); + return (prop?.Name, prop); } return property; diff --git a/Sieve/Services/SievePropertyMapper.cs b/Sieve/Services/SievePropertyMapper.cs index 0f8a656..f9c1837 100644 --- a/Sieve/Services/SievePropertyMapper.cs +++ b/Sieve/Services/SievePropertyMapper.cs @@ -32,7 +32,7 @@ namespace Sieve.Services { _sievePropertyMapper = sievePropertyMapper; (_fullName, _property) = GetPropertyInfo(expression); - _name = _property.Name; + _name = _fullName; _canFilter = false; _canSort = false; } @@ -97,18 +97,18 @@ namespace Sieve.Services public (string, PropertyInfo) FindProperty( bool canSortRequired, bool canFilterRequired, - string fullName, + string name, bool isCaseSensitive) { try { var result = _map[typeof(TEntity)] .FirstOrDefault(kv => - kv.Value.FullName.Equals(fullName, isCaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase) + kv.Value.Name.Equals(name, isCaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase) && (canSortRequired ? kv.Value.CanSort : true) && (canFilterRequired ? kv.Value.CanFilter : true)); - return (result.Value.FullName, result.Key); + return (result.Value?.FullName, result.Key); } catch (Exception ex) when (ex is KeyNotFoundException || ex is ArgumentNullException) {