mirror of
https://github.com/Biarity/Sieve.git
synced 2024-11-22 05:22:57 +01:00
Fixes with custom name setup
This commit is contained in:
parent
bd904dff8a
commit
440ebe8cc0
@ -11,6 +11,8 @@ namespace Sieve.Attributes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public string FullName => Name;
|
||||||
|
|
||||||
public bool CanSort { get; set; }
|
public bool CanSort { get; set; }
|
||||||
public bool CanFilter { get; set; }
|
public bool CanFilter { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
public interface ISievePropertyMetadata
|
public interface ISievePropertyMetadata
|
||||||
{
|
{
|
||||||
string Name { get; set; }
|
string Name { get; set; }
|
||||||
string FullName { get; set; }
|
string FullName { get; }
|
||||||
bool CanFilter { get; set; }
|
bool CanFilter { get; set; }
|
||||||
bool CanSort { get; set; }
|
bool CanSort { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ namespace Sieve.Services
|
|||||||
if(property.Item1 == null)
|
if(property.Item1 == null)
|
||||||
{
|
{
|
||||||
var prop = FindPropertyBySieveAttribute<TEntity>(canSortRequired, canFilterRequired, name, _options.Value.CaseSensitive);
|
var prop = FindPropertyBySieveAttribute<TEntity>(canSortRequired, canFilterRequired, name, _options.Value.CaseSensitive);
|
||||||
return (prop.Name, prop);
|
return (prop?.Name, prop);
|
||||||
}
|
}
|
||||||
return property;
|
return property;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ namespace Sieve.Services
|
|||||||
{
|
{
|
||||||
_sievePropertyMapper = sievePropertyMapper;
|
_sievePropertyMapper = sievePropertyMapper;
|
||||||
(_fullName, _property) = GetPropertyInfo(expression);
|
(_fullName, _property) = GetPropertyInfo(expression);
|
||||||
_name = _property.Name;
|
_name = _fullName;
|
||||||
_canFilter = false;
|
_canFilter = false;
|
||||||
_canSort = false;
|
_canSort = false;
|
||||||
}
|
}
|
||||||
@ -97,18 +97,18 @@ namespace Sieve.Services
|
|||||||
public (string, PropertyInfo) FindProperty<TEntity>(
|
public (string, PropertyInfo) FindProperty<TEntity>(
|
||||||
bool canSortRequired,
|
bool canSortRequired,
|
||||||
bool canFilterRequired,
|
bool canFilterRequired,
|
||||||
string fullName,
|
string name,
|
||||||
bool isCaseSensitive)
|
bool isCaseSensitive)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = _map[typeof(TEntity)]
|
var result = _map[typeof(TEntity)]
|
||||||
.FirstOrDefault(kv =>
|
.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)
|
&& (canSortRequired ? kv.Value.CanSort : true)
|
||||||
&& (canFilterRequired ? kv.Value.CanFilter : 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)
|
catch (Exception ex) when (ex is KeyNotFoundException || ex is ArgumentNullException)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user