Class Query
Represents a query for filtering events from the event store. Multiple QueryItems are combined with OR logic.
public class Query
- Inheritance
-
Query
- Inherited Members
Examples
Example JSON representation of a Query that matches Events that are either:
- of type EventType1 OR EventType2
- tagged tag1 AND tag2
- of type EventType2 OR EventType3 AND tagged tag1 AND tag3
{
"items": [
{
"types": ["EventType1", "EventType2"]
},
{
"tags": ["tag1", "tag2"]
},
{
"types": ["EventType2", "EventType3"],
"tags": ["tag1", "tag3"]
}
]
}
Properties
QueryItems
List of query items. Events matching ANY of these items will be returned (OR logic).
public List<QueryItem> QueryItems { get; set; }
Property Value
Methods
All()
Creates a query that matches all events.
public static Query All()
Returns
FromEventTypes(params string[])
Creates a query that matches events of any of the specified types.
public static Query FromEventTypes(params string[] eventTypes)
Parameters
eventTypesstring[]
Returns
FromItems(params QueryItem[])
Creates a query from a collection of query items.
public static Query FromItems(params QueryItem[] items)
Parameters
itemsQueryItem[]
Returns
FromTags(params Tag[])
Creates a query that matches events with all of the specified tags.
public static Query FromTags(params Tag[] tags)
Parameters
tagsTag[]
Returns
Matches(SequencedEvent)
Returns true if the given event matches this query using the same OR/AND logic applied by the event store. Useful for in-memory filtering and unit testing.
public bool Matches(SequencedEvent evt)
Parameters
evtSequencedEvent
Returns
Remarks
Query.All() (empty QueryItems) matches every event.
Within a QueryItem: types are OR'd, tags are AND'd, then the two groups are AND'd together. Multiple QueryItems are OR'd.