Path: redb/redb.Examples/Examples/E032_StringContainsIgnoreCase.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Examples/Examples/E032_StringContainsIgnoreCase.cs
----
using System.Diagnostics;
using redb.Core;
using redb.Examples.Models;
using redb.Examples.Output;
namespace redb.Examples.Examples;
///
/// Filter using case-insensitive String.Contains.
/// Uses StringComparison.OrdinalIgnoreCase for accent/case agnostic search.
///
[ExampleMeta("E032", "Where - Contains IgnoreCase", "Query",
ExampleTier.Free, 32, "Where", "String", "Contains", "IgnoreCase", RelatedApis = ["IRedbQueryable.Where"])]
public class E032_StringContainsIgnoreCase : ExampleBase
{
public override async Task RunAsync(IRedbService redb)
{
var sw = Stopwatch.StartNew();
// Case-insensitive search: "smith" matches "Smith", "SMITH", etc.
var query = redb.Query()
.Where(e => e.LastName.Contains("smith", StringComparison.OrdinalIgnoreCase))
.Take(100);
// Uncomment to see generated SQL:
//var sql = await query.ToSqlStringAsync();
//Console.WriteLine(sql);
var result = await query.ToListAsync();
sw.Stop();
var sample = result.FirstOrDefault()?.Props?.LastName ?? "N/A";
return Ok("E032", "Where - Contains IgnoreCase", ExampleTier.Free, sw.ElapsedMilliseconds, result.Count,
[$"Filter: 'smith' (case-insensitive)", $"Found: {sample}"]);
}
}