Skip to main content

Query With Exact Match

By default, the Where method in Query uses a case-insensitive match.

To perform a case-sensitive match you should use the exact parameter.

Syntax

IRavenQueryable<T> Where<T>(Expression<Func<T, int, bool>> predicate, bool exact);

IRavenQueryable<T> Where<T>(Expression<Func<T, bool>> predicate, bool exact);
Parameters
predicateExpression<Func<T, int, bool>>Predicate with match condition
exactboolIndicates if predicate should be matched in case-sensitive manner

Example I - Query With Exact Match

// load all entities from 'Employees' collection
// where FirstName equals 'Robert' (case sensitive match)
List<Employee> employees = session
.Query<Employee>()
.Where(x => x.FirstName == "Robert", exact: true)
.ToList();

Example II - Query With Inner Exact Match

// return all entities from 'Orders' collection
// which contain at least one order line with
// 'Singaporean Hokkien Fried Mee' product
// perform a case-sensitive match
List<Order> orders = session
.Query<Order>()
.Where(x => x.Lines.Any(p => p.ProductName == "Singaporean Hokkien Fried Mee"), exact: true)
.ToList();