SelectQuery Constructor (String)


Initializes a new instance of the SelectQuery class for the specified query or the specified class name.

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

public SelectQuery(
	string queryOrClassName


Type: System.String

The entire query or the class name to use in the query. The parser in this class attempts to parse the string as a valid WQL SELECT query. If the parser is unsuccessful, it assumes the string is a class name.

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

using System; 
using System.Management;

class Sample 
    public static void Main(string[] args) 
        SelectQuery sQuery = 
            new SelectQuery(
            "SELECT * FROM Win32_Service WHERE State='Stopped'"); 

        // or 

        // This is equivalent to "SELECT * FROM Win32_Service"
        SelectQuery query = new SelectQuery("Win32_Service");

.NET Framework
Available since 1.1
Return to top