Table of Contents

Class Query

Namespace
Opossum.Core
Assembly
Opossum.dll

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

List<QueryItem>

Methods

All()

Creates a query that matches all events.

public static Query All()

Returns

Query

FromEventTypes(params string[])

Creates a query that matches events of any of the specified types.

public static Query FromEventTypes(params string[] eventTypes)

Parameters

eventTypes string[]

Returns

Query

FromItems(params QueryItem[])

Creates a query from a collection of query items.

public static Query FromItems(params QueryItem[] items)

Parameters

items QueryItem[]

Returns

Query

FromTags(params Tag[])

Creates a query that matches events with all of the specified tags.

public static Query FromTags(params Tag[] tags)

Parameters

tags Tag[]

Returns

Query

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

evt SequencedEvent

Returns

bool

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.