### Install SearchExtensions NuGet Package Source: https://ninjanye.github.io/SearchExtensions/index.html Install the SearchExtensions library using the Package Manager Console. ```powershell PM> Install-Package NinjaNye.SearchExtensions ``` -------------------------------- ### Combine StartsWith and Containing with Single Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to search where a single property starts with one term and contains another. This is useful for precise filtering. ```csharp var result = queryableData.Search(x => x.Property1) .StartsWith("abc") .Containing("mno"); ``` -------------------------------- ### Filter Results by Levenshtein Distance Source: https://ninjanye.github.io/SearchExtensions/levenshtein.html After calculating Levenshtein distances, you can filter the results using the ILevenshteinDistance interface. This example retrieves items where the distance is less than 5 and selects the original item. ```csharp var result = data.LevenshteinDistanceOf(x => x.StringOne) .ComparedTo("test") .Where(x => x.Distance < 5) .Select(x => x.Item); ``` -------------------------------- ### Manual Implementation of Between Search Source: https://ninjanye.github.io/SearchExtensions/simplesearch.html Illustrates the equivalent manual LINQ query for a 'Between' search without using the SearchExtensions library. ```csharp var result = testContext.TestModels .Where(x => (x.DecOne > 9.99 && x.DecOne < 29.99) || (x.DecTwo > 9.99 && x.DecTwo < 29.99) || (x.DecThree > 9.99 && x.DecThree < 29.99)) ``` -------------------------------- ### Combine Multiple Search Extensions for Complex Queries Source: https://ninjanye.github.io/SearchExtensions/simplesearch.html Demonstrates chaining multiple SearchExtension methods to build a complex query, including string containment, numeric range, and date comparisons. ```csharp testContext.Products.Search(x => x.Title, x => x.SubTitle) .Containing("demo", "example", "search") .Search(x => x.Doller, x => x.Euro, x => x.GBP) .Between(9.99, 29.99) .Search(x => x.StartDate) .LessThanOrEqualTo(DateTime.Today); ``` -------------------------------- ### IEnumerable Search with Multiple Culture Switches Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Demonstrates performing an in-memory search on an IEnumerable collection while switching string comparison cultures multiple times. ```csharp var result = enumerableData.Search(x => x.Property1) .SetCulture(StringComparison.OrdinalIgnoreCase) .StartsWith("abc") // Uses OrdinalIgnoreCase .SetCulture(StringComparison.Ordinal) .EndsWith("xyz") // Uses Ordinal .SetCulture(StringComparison.CurrentCulture) .Containing("mno"); // Uses CurrentCulture ``` -------------------------------- ### Search multiple properties with Soundex Source: https://ninjanye.github.io/SearchExtensions/soundex.html Use this to find records where any of multiple properties sound like a single search term. ```csharp var result = data.Search(x => x.Property1, x => x.PropertyTwo) .Soundex("test") ``` -------------------------------- ### Perform StartsWith Search on Multiple Properties with Multiple Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where any of the specified properties begin with any of the provided search terms. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2, x => x.Property3) .StartsWith("searchTerm1", "searchTerm2", "searchTerm3"); ``` -------------------------------- ### Perform StartsWith Search on Multiple Properties Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where any of the specified properties begin with a single search term. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2, x => x.Property3) .StartsWith("searchTerm"); ``` -------------------------------- ### Combine StartsWith and Containing with Multiple Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to search across multiple properties with multiple search terms for each condition. This allows for broader, more flexible searches. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2) .StartsWith("abc", "ninja") .Containing("xyz", "extensions") ``` -------------------------------- ### Search multiple properties with multiple Soundex terms Source: https://ninjanye.github.io/SearchExtensions/soundex.html Use this to find records where any of multiple properties sound like any of multiple search terms. ```csharp var result = data.Search(x => x.Property1, x => x.PropertyTwo) .Soundex("test", "another") ``` -------------------------------- ### Search single property with Soundex Source: https://ninjanye.github.io/SearchExtensions/soundex.html Use this to find records where a single property sounds like a single search term using the Soundex algorithm. ```csharp var result = data.Search(x => x.Property1).Soundex("test") ``` -------------------------------- ### Perform StartsWith Search with Multiple Search Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where a single property begins with any of the provided search terms. ```csharp var result = queryableData.Search(x => x.Property1) .StartsWith("search", "term"); ``` -------------------------------- ### Mixing Ranked Search with Other Fluent API Methods Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Combines ranked search with other fluent API methods like StartsWith and Containing, then orders by relevance. ```csharp var result = context.Users.Search(x => x.FirstName, x => x.LastName, x => x.MiddleName) .StartsWith("john") .Containing("smith") .ToRanked() // Order by Hits property of IRanked .OrderByDescending(r => r.Hits) .Take(10); ``` -------------------------------- ### Search multiple properties with ReverseSoundex Source: https://ninjanye.github.io/SearchExtensions/soundex.html Use this to find records where any of multiple properties sound like a single search term using the ReverseSoundex algorithm. ```csharp var result = data.Search(x => x.Property1, x => x.PropertyTwo) .ReverseSoundex("test") ``` -------------------------------- ### Search multiple properties with multiple ReverseSoundex terms Source: https://ninjanye.github.io/SearchExtensions/soundex.html Use this to find records where any of multiple properties sound like any of multiple search terms using the ReverseSoundex algorithm. ```csharp var result = data.Search(x => x.Property1, x => x.PropertyTwo) .ReverseSoundex("test", "another") ``` -------------------------------- ### Search Multiple Properties Containing All Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to search where all specified search terms must be present across multiple properties. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2, x => x.Property3) .ContainingAll("search", "term"); ``` -------------------------------- ### Perform StartsWith Search on Single Property Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where a single property begins with a specific search term. ```csharp var result = queryableData.Search(x => x.Property1) .StartsWith("searchTerm"); ``` -------------------------------- ### Perform EqualTo Search on Multiple Integer Properties Source: https://ninjanye.github.io/SearchExtensions/simplesearch.html Use the EqualTo method to find records where any of the specified integer properties match any of the provided search values. ```csharp var result = testContext.TestModels.Search(x => x.IntegerOne, x => x.IntegerTwo) .EqualTo(1, 5, 8, 12); ``` -------------------------------- ### Search single property with ReverseSoundex Source: https://ninjanye.github.io/SearchExtensions/soundex.html Use this to find records where a single property sounds like a single search term using the ReverseSoundex algorithm. ```csharp var result = data.Search(x => x.Property1).ReverseSoundex("test") ``` -------------------------------- ### Search single property with multiple Soundex terms Source: https://ninjanye.github.io/SearchExtensions/soundex.html Use this to find records where a single property sounds like any of multiple search terms. ```csharp var result = data.Search(x => x.Property1) .Soundex("test", "another") ``` -------------------------------- ### Ranked Search: Multiple Terms, Multiple Properties Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Performs a ranked search for multiple terms across multiple specified properties. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2) .Containing("searchTerm1", "searchTerm2", "searchTerm3") .ToRanked(); ``` -------------------------------- ### IEnumerable Search with Single Culture Setting Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Performs an in-memory search on an IEnumerable collection, setting a specific culture for string comparison. ```csharp var result = enumerableData.Search(x => x.Property1) // Set culture for comparison .SetCulture(StringComparison.OrdinalIgnoreCase) .StartsWith("abc") .EndsWith("xyz") .Containing("mno"); ``` -------------------------------- ### Search Multiple Properties for Term1 AND Multiple Properties for Term2 Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to search where a single search term exists within Property1 OR Property2, AND a single search term exists within Property3 OR Property4. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2) .Containing("searchTerm") .Search(x => x.Property3, x => x.Property4) .Containing("searchTerm"); ``` -------------------------------- ### Perform EqualTo Search on Multiple Properties with Multiple Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where any of the specified properties match any of the provided search terms. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2, x => x.Property3) .EqualTo("searchTerm1", "searchTerm2", "searchTerm3"); ``` -------------------------------- ### Perform EqualTo Search on Multiple Properties Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where any of the specified properties match a single search term. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2, x => x.Property3) .EqualTo("searchTerm"); ``` -------------------------------- ### Search Single Property Containing All Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to search where a single property must contain all of the specified search terms. ```csharp var result = queryableData.Search(x => x.Property1) .ContainingAll("search", "term"); ``` -------------------------------- ### Search single property with multiple ReverseSoundex terms Source: https://ninjanye.github.io/SearchExtensions/soundex.html Use this to find records where a single property sounds like any of multiple search terms using the ReverseSoundex algorithm. ```csharp var result = data.Search(x => x.Property1) .ReverseSoundex("test", "another") ``` -------------------------------- ### Search Multiple Properties for Term1 AND Single Property for Multiple Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to search where a single search term exists in Property1 OR Property2, AND any of the multiple search terms exist within Property3. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2) .Containing("searchTerm") .Search(x => x.Property3) .Containing("another", "term"); ``` -------------------------------- ### Perform EqualTo Search with Multiple Search Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where a single property matches any of the provided search terms. ```csharp var result = queryableData.Search(x => x.Property1) .EqualTo("search", "term"); ``` -------------------------------- ### Ranked Search: Single Term, Multiple Properties Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Performs a ranked search for a single term across multiple specified properties. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2, x => x.Property3) .Containing("searchTerm") .ToRanked(); ``` -------------------------------- ### Ranked Search: Multiple Terms, Single Property Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Performs a ranked search for multiple terms within a single specified property. ```csharp var result = queryableData.Search(x => x.Property1) .Containing("searchTerm1", "searchTerm2", "searchTerm3") .ToRanked(); ``` -------------------------------- ### Search Single Property Containing Single Term (AND) Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to perform an AND search where a single property must contain both specified search terms. ```csharp var result = queryableData.Search(x => x.Property1) .Containing("searchTerm1") .Containing("searchTerm2"); ``` -------------------------------- ### Perform EqualTo Search on Single Property Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where a single property exactly matches a single search term. ```csharp var result = queryableData.Search(x => x.Property1) .EqualTo("searchTerm"); ``` -------------------------------- ### Perform Between Search on Multiple Decimal Properties Source: https://ninjanye.github.io/SearchExtensions/simplesearch.html Use the Between method to find records where any of the specified decimal properties fall within the given range (exclusive of bounds). ```csharp var result = testContext.TestModels.Search(x => x.DecOne, x => x.DecTwo, x => x.DecThree) .Between(9.99, 29.99); ``` -------------------------------- ### Search Multiple Properties Containing Multiple Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to search for multiple search terms across multiple string properties. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2, x => x.Property3) .Containing("searchTerm1", "searchTerm2", "searchTerm3"); ``` -------------------------------- ### IRanked Interface Definition Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Defines the structure of a ranked search result, containing the hit count and the item itself. ```csharp public interface IRanked { int Hits { get; } T Item { get; } } ``` -------------------------------- ### Retrieve Top 10 Relevant Search Results Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Retrieves the top 10 most relevant search results by ordering ranked results by hit count. ```csharp var result = context.Users.Search(x => x.FirstName, x => x.LastName, x => x.MiddleName) .Containing("John") .ToRanked() // Order by Hits property of IRanked .OrderByDescending(r => r.Hits) .Take(10); ``` -------------------------------- ### Search Multiple Properties Containing Single Term Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to search for a single search term across multiple string properties. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2, x => x.Property3) .Containing("searchTerm"); ``` -------------------------------- ### Perform LessThan Search on Multiple Date Properties Source: https://ninjanye.github.io/SearchExtensions/simplesearch.html Use the LessThan method to find records where any of the specified date properties are earlier than the provided date. ```csharp var date = new DateTime(2013, 5, 13) var result = testContext.TestModels.Search(x => x.DateOne, x => DateTwo, x => x.DateThree) .LessThan(date); ``` -------------------------------- ### Search Single Property Containing Single Term Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to search for a single search term within a single string property. ```csharp var result = queryableData.Search(x => x.Property1) .Containing("searchTerm"); ``` -------------------------------- ### Ranked Search: Single Term, Single Property Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Performs a ranked search for a single term within a single property. ```csharp var result = queryableData.Search(x => x.Property1) .Containing("searchTerm") .ToRanked(); ``` -------------------------------- ### Perform EndsWith Search on Multiple Properties with Multiple Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where any of the specified properties end with any of the provided search terms. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2, x => x.Property3) .EndsWith("searchTerm1", "searchTerm2", "searchTerm3"); ``` -------------------------------- ### Search Single Property Containing Multiple Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to search for multiple search terms within a single string property. ```csharp var result = queryableData.Search(x => x.Property1) .Containing("search", "term"); ``` -------------------------------- ### Perform GreaterThan Search on Multiple Date Properties Source: https://ninjanye.github.io/SearchExtensions/simplesearch.html Use the GreaterThan method to find records where any of the specified date properties are later than the provided date. ```csharp var date = new DateTime(2013, 5, 13) var result = testContext.TestModels.Search(x => x.DateOne, x => DateTwo, x => x.DateThree) .GreaterThan(date); ``` -------------------------------- ### Perform EndsWith Search on Multiple Properties Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where any of the specified properties end with a single search term. ```csharp var result = queryableData.Search(x => x.Property1, x => x.Property2, x => x.Property3) .EndsWith("searchTerm"); ``` -------------------------------- ### Calculate Levenshtein Distance Between Two Properties Source: https://ninjanye.github.io/SearchExtensions/levenshtein.html Calculate the Levenshtein distance between two string properties of the same model using LevenshteinDistanceOf and ComparedTo. This is useful for comparing related string fields within your data. ```csharp context.TestModels.LevenshteinDistanceOf(x => x.StringOne) .ComparedTo(x => x.StringTwo); ``` -------------------------------- ### Calculate Levenshtein Distance Between Property and String Source: https://ninjanye.github.io/SearchExtensions/levenshtein.html Use LevenshteinDistanceOf and ComparedTo to find the Levenshtein distance between a specified string property and a given string value. This method operates on IEnumerable data. ```csharp context.TestModels.LevenshteinDistanceOf(x => x.StringOne) .ComparedTo("test"); ``` -------------------------------- ### Perform EndsWith Search with Multiple Search Terms Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where a single property ends with any of the provided search terms. ```csharp var result = queryableData.Search(x => x.Property1) .EndsWith("search", "term", "test"); ``` -------------------------------- ### Perform EndsWith Search on Single Property Source: https://ninjanye.github.io/SearchExtensions/stringsearch.html Use this to find records where a single property ends with a specific search term. ```csharp var result = queryableData.Search(x => x.Property1) .EndsWith("searchTerm"); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.