DeviceRepositoryV3.SearchAll Method

Search devices by search text.

Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public ISimpleCollection<SimpleDeviceV1> SearchAll(
	string searchText,
	Properties properties,
	bool includeArchived
)

Parameters

searchText  String
Text to search.
properties  Properties
The properties.
includeArchived  Boolean
if set to true include archived.

Return Value

ISimpleCollection<SimpleDeviceV1>
Collection of device ids

Implements

ISimpleClientDeviceRepositoryV3.SearchAll(String, Properties, Boolean)
Example
The following example demonstrates how to search for all devices using a search text, with optional filtering properties (None, Basic, All) and an option to include archived devices.
C#
using System;
using Gamanet.C4.SDK;
using Gamanet.C4.SimpleInterfaces;

public class Example
{
    static void Main()
    {
        // Create instance of simple client
        var client = new SimpleClient(ConnectorConfiguration.HttpClient);

        ConnectionInfoV1 token;
        // Connect to local server
        var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support", out token);

        if (connectionResult != ConnectionResult.Successful)
        {
            Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult);
            return;
        }

        Console.WriteLine("Connection result: {0}", connectionResult);
        Console.WriteLine();

        // You need to have installed the Demo Access Device package from https://my.c4portal.com/plugins/
        var exampleBusCategory = client.EntityDefinitions.Get(Guid.Parse("4810e0c6-9391-490c-a646-ca9643dd1ca5")).Id;
        // Create the Example Device
        var exampleDeviceArchived = new SimpleDeviceV1(
            Guid.NewGuid(),
            "BUScontrollerARCHIVED",
            EntityRoot.Device,
            exampleBusCategory
            );

        var exampleDevice = new SimpleDeviceV1(
            Guid.NewGuid(),
            "JustBusController",
            EntityRoot.Device,
            exampleBusCategory
            );
        // Create device under device root in db
        client.Devices.Create(exampleDevice);
        client.Devices.Create(exampleDeviceArchived);

        // Get all devices to check whether they were created
        var devices = client.Devices.GetAll(EntityRoot.DeviceSuperRoot, Properties.All, true);
        foreach ( var device in devices)
        {
            Console.WriteLine($"Device Name: {device.Name}  Archived: {device.Archived}");
        }

        //Archive one device
        client.Devices.Archive(exampleDeviceArchived);

        var archivedDevices = client.Devices.SearchAll("Bus", Properties.All, true);
        var notArchivedDevices = client.Devices.SearchAll("B", Properties.All, false);

        // Print out results. Result with archved devices should contain device name 'BUScontrollerARCHIVED'
        foreach(var device in archivedDevices)
        {
            Console.WriteLine($"Device Name: {device.Name}  Archived: {device.Archived}");
        }

        foreach (var device in notArchivedDevices)
        {
            Console.WriteLine($"Device Name: {device.Name}  Archived: {device.Archived}");
        }

        // Disconnect from server
        client.Disconnect();
    }
}
See Also

Reference

DeviceRepositoryV3 Class
Gamanet.C4.SDK Namespace