Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Filtering

SQL Server 2008 R2

The example in this topic demonstrates how to filter an event stream based on specified conditions. Filters are expressed through a where clause. That is, the filter propagates the event to the output stream only if the expression defined in the where clause evaluates to true. A filter operates on an event CepStream<T> and yields an event CepStream<T>.

In the following example, the events in the event stream someStream are limited to events in which the value in payload field i is greater than 10. Events that do not meet this condition are not passed on to the output stream.

// Assuming the following input event type:
public class MyPayload
{
    public int i;
}

var queryFilter = from c in someStream
                  where c.i > 10
                  select c;

The filter predicate can call any .NET method available to the executing process. The following example calls the Math.Abs method.

var queryFilter = from c in someStream
                  where Math.Abs(c.i) > 10
                  select c;

Culture-specific attributes can be used as parameters. The following example specifies the CultureInfo.InvariantCulture attribute.

var queryFilter = from c in someStream
                  where string.Compare(Convert.ToString(c.value),
                                       c.str,
                                       true,
                                       CultureInfo.InvariantCulture) > 0
                  select c;


Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.