DeviceRepository.Get(Guid, String) Method

Get the specified device by identifier with specified prefix properties.

Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public SimpleDeviceV1 Get(
	Guid deviceId,
	string prefix
)

Parameters

deviceId  Guid
The device identifier.
prefix  String
The prefix.

Return Value

SimpleDeviceV1
SimpleDevice or null when does not exists

Implements

ISimpleClientDeviceRepositoryV1.Get(Guid, String)
Example
The following example illustrates how SimpleClient provides device by Id by data prefix
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();

        // Create the Example Device
        var exampleDevice = new SimpleDeviceV1(
            Guid.NewGuid(),
            "BUS",
            EntityRoot.Device,
            Guid.Parse("9c2246aa-5d43-414f-85d4-8c3b4e657236")
        );
        // Add device prefix
        exampleDevice.Data["prefix_Entity"] = exampleDevice.Name;
        // Create device under device root in db
        client.Devices.Create(exampleDevice);

        //Get the example device by "prefix_"
        var loadedExampleDevice = client.Devices.Get(exampleDevice.Id, "prefix_");

        Console.WriteLine(loadedExampleDevice.Name);

        // Disconnect from server
        client.Disconnect();
    }
}
The following example illustrates how SimpleClient provides device by Id by data prefix
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();

        // Create the Example Device
        var exampleDevice = new SimpleDeviceV1(
            Guid.NewGuid(),
            "BUS",
            EntityRoot.Device,
            Guid.Parse("9c2246aa-5d43-414f-85d4-8c3b4e657236")
        );
        // Add device prefix
        exampleDevice.Data["prefix_Entity"] = exampleDevice.Name;
        // Create device under device root in db
        client.Devices.Create(exampleDevice);

        // Get the example device
        var loadedExampleDevices = client.Devices.Get(exampleDevice.Id, null);

        Console.WriteLine(loadedExampleDevices.Name);

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

Reference

DeviceRepository Class
Get Overload
Gamanet.C4.SDK Namespace