Redigera

Dela via


WqlEventQuery.HavingCondition Property

Definition

Gets or sets the condition to be applied to the aggregation of events, based on the number of events received.

public:
 property System::String ^ HavingCondition { System::String ^ get(); void set(System::String ^ value); };
public string HavingCondition { get; set; }
member this.HavingCondition : string with get, set
Public Property HavingCondition As String

Property Value

Returns a String value containing the condition applied to the aggregation of events, based on the number of events received.

Examples

The following example initializes a new WqlEventQuery and displays the event query string.

using System;
using System.Management;

public class EventSample
{
    public static void Main(string[] args)
    {
        WqlEventQuery query = new WqlEventQuery();
        query.EventClassName = "__InstanceCreationEvent";
        query.Condition = "TargetInstance ISA 'Win32_NTLogEvent'";
        query.GroupWithinInterval = new TimeSpan(0, 0, 10);
        System.Collections.Specialized.StringCollection collection =
            new System.Collections.Specialized.StringCollection();
        collection.Add("TargetInstance.SourceName");
        query.GroupByPropertyList = collection;
        query.HavingCondition = "NumberOfEvents > 25";

        Console.WriteLine(query.QueryString);
        return;
    }
}
Imports System.Management


Public Class EventSample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        Dim query As New WqlEventQuery
        query.EventClassName = "__InstanceCreationEvent"
        query.Condition = "TargetInstance ISA 'Win32_NTLogEvent'"
        query.GroupWithinInterval = New TimeSpan(0, 0, 10)
        Dim collection As New System.Collections.Specialized. _
            StringCollection
        collection.Add("TargetInstance.SourceName")
        query.GroupByPropertyList = collection
        query.HavingCondition = "NumberOfEvents > 25"

        MessageBox.Show(query.QueryString)

    End Function 'Main
End Class

Remarks

Setting this property value overrides any previous value stored in the object. The query string is rebuilt to reflect the new grouping condition.

Property Value

Null, if no aggregation or no condition should be applied; otherwise, a condition of the form "NumberOfEvents <operator> <value>".

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to