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 | ||
---|---|---|
predicate | Expression<Func<T, int, bool>> | Predicate with match condition |
exact | bool | Indicates 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();
// load all entities from 'Employees' collection
// where FirstName equals 'Robert' (case sensitive match)
List<Employee> employees = await asyncSession
.Query<Employee>()
.Where(x => x.FirstName == "Robert", exact: true)
.ToListAsync();
from Employees where exact(FirstName == 'Robert')
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();
// 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 = await asyncSession
.Query<Order>()
.Where(x => x.Lines.Any(p => p.ProductName == "Singaporean Hokkien Fried Mee"), exact: true)
.ToListAsync();
from Orders
where exact(Lines[].ProductName == 'Singaporean Hokkien Fried Mee')