Skip to content

Commit

Permalink
Merge pull request #85 from bcc-code/search-case-insensitive
Browse files Browse the repository at this point in the history
use case insensitive properties for search on server side
  • Loading branch information
rvanoord authored Apr 2, 2024
2 parents 26f8f69 + 89b92ed commit 7a12dde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/BccCode.Linq/Server/CollectionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public static IQueryable<T> ApplyRuleFilter<T>(this IQueryable<T> source, Filter
sortDirection = ListSortDirection.Ascending;
}

// try find property by camel case
// try find property
var propertyInfo = typeof(T).GetProperty(propertyName,
BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty);
BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.IgnoreCase);

if (propertyInfo == null)
{
Expand Down Expand Up @@ -101,7 +101,7 @@ public static IQueryable<T> ApplyRuleFilter<T>(this IQueryable<T> source, Filter
yield return (propertyInfo, sortDirection);
}
}

/// <summary>
/// Applies query parameters to a <seealso cref="IQueryable"/> object.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/BccCode.Linq/Server/Filter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using BccCode.Linq;
using BccCode.Linq.Server;
*/
using System.Reflection;
using BccCode.Linq.Extensions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -87,11 +88,10 @@ private void _parse(string json)
{
var deserializedJson = FilterDeserializationHelpers.DeserializeJsonRule(json);

var propertyMetadata = typeof(T).GetProperties();

foreach (var (key, value) in deserializedJson)
{
var propertyInfo = propertyMetadata.FirstOrDefault(x => x.Name.ToLower() == key.ToLower());
var propertyInfo = typeof(T).GetProperty(key,
BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.IgnoreCase);

if (new[] { "_and", "_or" }.Contains(key))
{
Expand Down

0 comments on commit 7a12dde

Please sign in to comment.