Table of Contents

Class EntityUtils

Namespace
Geotab.Checkmate
Assembly
Geotab.Checkmate.ObjectModel.dll

Tools for dealing with Entity objects.

public static class EntityUtils
Inheritance
EntityUtils
Inherited Members

Methods

GetUniqueDevices<T>(IEnumerable<T>)

Gets the unique Device objects contained in all the logs.

public static HashSet<Device> GetUniqueDevices<T>(IEnumerable<T> records) where T : IDeviceProvider

Parameters

records IEnumerable<T>

The list of. IDeviceProvider

Returns

HashSet<Device>

A HashSet<T> of unique devices.

Type Parameters

T

The generic type of the list of records.

GetUnique<T, TConvertTo>(IEnumerable<T>, Func<T, TConvertTo>)

Pick out all T in entities, converting them to U, returning unique values for U. This is not optimized so don't use for large sets.

public static IEnumerable<TConvertTo> GetUnique<T, TConvertTo>(IEnumerable<T> entities, Func<T, TConvertTo> converter) where TConvertTo : IEntity

Parameters

entities IEnumerable<T>

The collection to iterate through.

converter Func<T, TConvertTo>

The function to convert to U from T.

Returns

IEnumerable<TConvertTo>

A collection that the unique U values are added to.

Type Parameters

T

The type of entity to convert.

TConvertTo

The type to convert to.

GetWithoutSystemAsync<T>(IAsyncEnumerable<T>)

Gets the collection without system entities.

public static IAsyncEnumerable<T> GetWithoutSystemAsync<T>(IAsyncEnumerable<T> collection) where T : Entity

Parameters

collection IAsyncEnumerable<T>

The collection of entities to search in.

Returns

IAsyncEnumerable<T>

The IAsyncEnumerable<T> collection without system entities.

Type Parameters

T

The generic type of the entity list.

GetWithoutSystem<T>(IEnumerable<T>)

Gets the collection without system entities.

public static IEnumerable<T> GetWithoutSystem<T>(IEnumerable<T> collection) where T : Entity

Parameters

collection IEnumerable<T>

The collection of entities to search in.

Returns

IEnumerable<T>

The IEnumerable<T> collection without system entities.

Type Parameters

T

The generic type of the entity list.

IsEqual<T1, T2>(IList<T1>, IList<T2>)

Compares if the two collections contains entities of type T with the same Id(s). This does not compare equality using Equals for each object but rather checks if the identity of the elements in each collection are the same.

public static bool IsEqual<T1, T2>(IList<T1> compare1, IList<T2> compare2) where T1 : IEntity where T2 : IEntity

Parameters

compare1 IList<T1>

The first list of entities to compare.

compare2 IList<T2>

The second list of entities to compare.

Returns

bool

True if each of the entities in collection1 has a matching entity in collection2. A match is positive if their Id(s) are equal.

Type Parameters

T1

The type of the first entity list.

T2

The type of the second entity list.

Exceptions

ArgumentException

collection2 or collection1.

ToDatabaseId(Id?)

Convert Id to physical database id object (key or guid).

public static object? ToDatabaseId(Id? id)

Parameters

id Id

The Id to convert.

Returns

object

The Id, Guid or long key of the object.