ExpressionQuery<T> Class
Represents a compiled query that can be applied to an IQueryable<T>.
public sealed class ExpressionQuery<T>Type parameters
T- The type of object to query against.
Remarks
This query type is designed for use with Entity Framework Core or other LINQ providers that translate expressions to SQL or other query languages.
Example
var queryBuilder = new ExpressionQueryBuilder<Person>();
queryBuilder.AddHandler("name", item => item.FullName);
var query = queryBuilder.Build("name:John");
// Apply works on any IQueryable<T>, such as an Entity Framework Core DbSet<T>
var people = new[] { new Person("John Doe", 30), new Person("Jane Doe", 25) }.AsQueryable();
var results = query.Apply(people).ToList();
Assert.Equal("John Doe", Assert.Single(results).FullName);Properties
| Name | Description |
|---|---|
| Diagnostics | Gets the problems found in the query, such as unbalanced parentheses or unknown keys, in the order they appear in it. |
| Predicate | Gets the compiled predicate expression, or null if the query matches all items. |
| Text | Gets the original query text. |
Diagnostics
ExpressionQuery`1.csGets the problems found in the query, such as unbalanced parentheses or unknown keys, in the order they appear in it.
public IReadOnlyList<QueryDiagnostic> Diagnostics { get; }Property value
IReadOnlyList<QueryDiagnostic>
Remarks
The query is still applied: the parts the diagnostics report are read leniently, mostly as text.
Predicate
ExpressionQuery`1.csGets the compiled predicate expression, or null if the query matches all items.
public Expression<Func<T, bool>>? Predicate { get; }Property value
Methods
| Name | Description |
|---|---|
| Apply(IQueryable<T>) | Applies the query to an IQueryable<T>. |
Apply(IQueryable<T>)
ExpressionQuery`1.csApplies the query to an IQueryable<T>.
public IQueryable<T> Apply(IQueryable<T> queryable)