Every word in the input will become separate search entry. Phrases between quotes: "
or '
will also become separate entries.
For example take a look at this search string: "Double quotes" 'Single quotes' Without quotes
.
There are these search entries:
1. Double quotes
2. Single quotes
3. Without
4. quotes
Every property can have their own search type.
Search types will generate SQL similar to:
SELECT ... WHERE name LIKE 'Lennon%';
SELECT ... WHERE name ILIKE 'beatles blog';
If the value provided for comparison is None
, it will be interpreted as a SQL NULL
.
SELECT ... WHERE name IS NULL;
SELECT ... WHERE name ILIKE '%Lennon%';
Every searchable property will be searched by every search entry.
For example:
SELECT ... FROM ...
WHERE (Name LIKE searchEntry1 OR Description ILIKE searchEntry1 OR ...)
AND (Name LIKE searchEntry2 OR Description ILIKE searchEntry2 OR ...)
AND (Name LIKE searchEntry3 OR Description ILIKE searchEntry3 OR ...)
AND (...)
By default properties do not have search types. Search type can be customized via Fluent API or attribute.
.ConfigureEntity<Product>(entityOptionsBuilder =>
{
entityOptionsBuilder.ConfigureProperty(product => product.Name, builder =>
{
builder.SetSearchType(SearchType.ExactMatchCaseInsensitive);
});
});
[NetForgeProperty(SearchType = SearchType.StartsWithCaseSensitive)]
public string Name { get; set; }
You can configure your own search.
.ConfigureEntity<Shop>(entityOptionsBuilder =>
{
entityOptionsBuilder
.ConfigureSearch((serviceProvider, query, searchTerm) =>
{
return query.Where(e => e.Name.Contains(searchTerm));
});
})
You can use ServiceProvider
to access your services.