Search
Name | Movie Director | Movie Genre | Released |
---|---|---|---|
Movie with <b>bold</b> | This Guy | Test | |
The Godfather | The Godfather | Mob | 1972 |
Citizen Kane | Orson Welles | Drama | 1941 |
@(await Html
.SimpleGrid(Model)
.AddColumnsForModel()
.AddSearch("Movie Name",
(source, query) => source.Where(movie => movie.Name.Contains(query, StringComparison.OrdinalIgnoreCase)))
.AddSearch("Name/Director/Genre",
(source, query) => source.Where(movie =>
movie.Name.Contains(query, StringComparison.OrdinalIgnoreCase) ||
movie.Director.Contains(query, StringComparison.OrdinalIgnoreCase) ||
movie.Genre.Contains(query, StringComparison.OrdinalIgnoreCase)))
.AddSearch("Release Year",
(source, query) => int.TryParse(query, out int result)
? source.Where(movie => movie.Released == result)
: source.Where(movie => false))
.AddPager(options =>
{
options.Botttom();
options.RowsPerPage = 3;
})
.RenderAsync())
Each call to AddSearch
adds an item in the dropdown.
Note that when using Entity Framework, you don't need StringComparision.OrdinalIgnoreCase
as
by default SQL will ignore case and specifying this in Contains may not work.