Export (0) Print
Expand All

SelectQuery Constructor (Boolean, String)

Initializes a new instance of the SelectQuery class for a schema query, optionally specifying a condition.

Namespace:  System.Management
Assembly:  System.Management (in System.Management.dll)

public SelectQuery(
	bool isSchemaQuery,
	string condition


Type: System.Boolean

true to indicate that this is a schema query; otherwise, false. A false value is invalid in this constructor.

Type: System.String

The condition to be applied to form the result set of classes.

.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.

The following example initializes a SelectQuery by specifying a condition.

using System;
using System.Management;

public class Sample 
    public static void Main(string[] args) 
        SelectQuery s = 
            new SelectQuery(true,
            "__CLASS = 'Win32_Service'");

        ManagementObjectSearcher searcher = 
            new ManagementObjectSearcher(

        foreach (ManagementObject service in searcher.Get()) 
            // show the class

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft