Skip to content

Commit

Permalink
Feature/16740/18399/tren search and or problem (#132)
Browse files Browse the repository at this point in the history
* fix: WhereContains overloaded

---------

Co-authored-by: Altay Gençaslan <altay.gencaslan@ext.kocdigital.com>
  • Loading branch information
altaygencaslan and Altay Gençaslan committed May 13, 2024
1 parent 4b59efa commit fe367dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;netstandard2.1</TargetFrameworks>
<Version>3.2.0</Version>
<Version>3.2.1</Version>
<Description>
- 3.2.1
* WhereContains overloaded

- 3.2.0
* WhereContains use to AndAlso or OrElse

Expand Down
17 changes: 17 additions & 0 deletions Carbon.Domain.EntityFrameworkCore.Extensions/EFExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,23 @@ public static async Task<PagedList<T>> ToPagedListEntityAsync<T>(
return result;
}

/// <summary>
/// Filters an IQueryable based on whether any word in the search term exists in the specified property's string value, using a case-insensitive comparison.
/// </summary>
/// <typeparam name="T">The type of elements in the IQueryable.</typeparam>
/// <param name="query">The IQueryable to filter.</param>
/// <param name="selector">Expression specifying the property to search within.</param>
/// <param name="search">The search term containing one or more words.</param>
/// <param name="searchByWords">A boolean value indicating whether to search for individual words in the search term (default is false).</param>
/// <returns>The filtered IQueryable containing elements where any word in the search term exists in the specified property's string value.</returns>
/// <remarks>
/// This method performs a case-insensitive search. If searchByWords is false, it performs a normal contains search for the entire search term. If searchByWords is true, it splits the search term into words and checks if any word exists in the specified property's string value.
/// </remarks>
public static IQueryable<T> WhereContains<T>(this IQueryable<T> query, Expression<Func<T, string>> selector, string search, bool searchByWords = false)
{
return WhereContains(query, selector, new List<string> { search }, searchByWords);
}

/// <summary>
/// Filters an IQueryable based on whether any word in the search term exists in the specified property's string value, using a case-insensitive comparison.
/// </summary>
Expand Down

0 comments on commit fe367dc

Please sign in to comment.