Class DataModelExtensions
Extensions for Data Models.
Inherited Members
Namespace: Cognite.Extensions.DataModels
Assembly: Cognite.Extensions.dll
Syntax
public static class DataModelExtensions
Methods
| Edit this page View SourceLoadEdges<T>(DataModelsResource, InstancesFilter, CancellationToken)
Return a list of edges containing data of type T
.
Declaration
public static IAsyncEnumerable<Edge<T>> LoadEdges<T>(this DataModelsResource resource, InstancesFilter filter, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DataModelsResource | resource | Query resource |
InstancesFilter | filter | Initial filter |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
IAsyncEnumerable<Edge<T>> | Async iterator of returned edges. |
Type Parameters
Name | Description |
---|---|
T | Type of data in response. You can use JsonNode or JsonElement to retrieve anything. |
LoadInstances<T, R>(DataModelsResource, InstancesFilter, CancellationToken)
Load a list of instances of type T
, containing data of type R
.
The filter filter
will be applied.
This follows cursors automatically.
Declaration
public static IAsyncEnumerable<T> LoadInstances<T, R>(this DataModelsResource resource, InstancesFilter filter, CancellationToken token) where T : BaseInstance<R>
Parameters
Type | Name | Description |
---|---|---|
DataModelsResource | resource | Query resource |
InstancesFilter | filter | Initial filter |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
IAsyncEnumerable<T> | Async iterator of returned instances. |
Type Parameters
Name | Description |
---|---|
T | Type of response, typically either nodes or edges, but it is possible to use BaseInstance from the SDK to retrieve either. |
R | Type of data in the response. You can use JsonNode or JsonElement to retrieve anything. |
LoadNodes<T>(DataModelsResource, InstancesFilter, CancellationToken)
Return a list of nodes containing data of type T
.
Declaration
public static IAsyncEnumerable<Node<T>> LoadNodes<T>(this DataModelsResource resource, InstancesFilter filter, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DataModelsResource | resource | Query resource |
InstancesFilter | filter | Initial filter |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
IAsyncEnumerable<Node<T>> | Async iterator of returned nodes. |
Type Parameters
Name | Description |
---|---|
T | Type of data in response. You can use JsonNode or JsonElement to retrieve anything. |
QueryPaginated<T>(DataModelsResource, Query, QueryCursor, CancellationToken)
Query DMS and follow the returned cursors. This variant will only call DMS once.
DMS cursors are per-query, but since queries may be dependent on each other, it may be necessary to keep one cursor fixed while following another. This method handles that complicated iteration for queries that are one or more trees. This does not support queries that are more complex graphs.
The query may change between calls, but each new query must be stricter than any previous query.
Declaration
public static Task<DMSQueryResult<T>> QueryPaginated<T>(this DataModelsResource resource, Query query, QueryCursor cursor, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DataModelsResource | resource | Query resource |
Query | query | Query to use |
QueryCursor | cursor | Cursor |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<DMSQueryResult<T>> | A result containing data and an optional new cursor. |
Type Parameters
Name | Description |
---|---|
T | Type of returned instance data |
QueryPaginated<T>(DataModelsResource, Query, IEnumerable<string>?, CancellationToken)
Query DMS and follow the returned cursors. This variant will follow the cursors until they are exhausted.
DMS cursors are per-query, but since queries may be dependent on each other, it may be necessary to keep one cursor fixed while following another. This method handles that complicated iteration for queries that are one or more trees. This does not support queries that are more complex graphs.
Declaration
public static Task<Dictionary<string, List<BaseInstance<T>>>> QueryPaginated<T>(this DataModelsResource resource, Query query, IEnumerable<string>? queriesToNeverPaginate, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
DataModelsResource | resource | Query resource |
Query | query | Query to use |
IEnumerable<string> | queriesToNeverPaginate | List of queries that should never be paginated, because the caller knows that they will never return values more than once. This is a workaround for DMS always returning cursors, even if there are no more results. |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<Dictionary<string, List<BaseInstance<T>>>> | A result dict mapping from query ID to list of instances. |
Type Parameters
Name | Description |
---|---|
T | Type of returned instance data |