#### [DiGi\.PostgreSQL\.PartitionUniqueReference](DiGi.PostgreSQL.PartitionUniqueReference.Overview.md 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Overview')
## DiGi\.PostgreSQL\.PartitionUniqueReference Namespace
### Classes
## Modify Class
```csharp
public static class Modify
```
Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → Modify
### Methods
## Modify\.CleanTypesAsync\(NpgsqlConnection\) Method
Cleans up unused types from the database by removing those that are not associated with any partition\.
```csharp
public static System.Threading.Tasks.Task?> CleanTypesAsync(Npgsql.NpgsqlConnection? npgsqlConnection);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The connection to the PostgreSQL database\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.List<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A list of the types that were deleted, or null if the operation could not be performed\.
## Modify\.RemoveAsync\(NpgsqlConnection, IEnumerable\, bool\) Method
Removes the specified partition unique references from the database asynchronously\.
```csharp
public static System.Threading.Tasks.Task?> RemoveAsync(Npgsql.NpgsqlConnection? npgsqlConnection, System.Collections.Generic.IEnumerable partitionUniqueReferences, bool clean=true);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The connection to the PostgreSQL database\.
`partitionUniqueReferences` [System\.Collections\.Generic\.IEnumerable<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[PartitionUniqueReference](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.PartitionUniqueReference 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.PartitionUniqueReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')
The collection of partition unique references to be removed\.
`clean` [System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean')
A value indicating whether to perform cleanup of partitions and types after removal\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.HashSet<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[PartitionUniqueReference](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.PartitionUniqueReference 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.PartitionUniqueReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A HashSet of PartitionUniqueReference containing the successfully removed references, or `null` if the operation failed or no references were processed\.
## Modify\.UpdateAsync\\(this NpgsqlConnection, IEnumerable\, Func\, object, PartitionUniqueReferenceGeneratingEventHandler\) Method
Asynchronously updates the partition unique references in the PostgreSQL database for a collection of serializable objects\.
```csharp
public static System.Threading.Tasks.Task?> UpdateAsync(this Npgsql.NpgsqlConnection? npgsqlConnection, System.Collections.Generic.IEnumerable serializableObjects, System.Func dataTypeFunc, object? sender=null, DiGi.PostgreSQL.PartitionUniqueReference.Delegates.PartitionUniqueReferenceGeneratingEventHandler? partitionUniqueReferenceGeneratingEventHandler=null)
where USerializableObject : DiGi.Core.Interfaces.ISerializableObject;
```
#### Type parameters
`USerializableObject`
The type of the serializable object, which must implement [DiGi\.Core\.Interfaces\.ISerializableObject](https://learn.microsoft.com/en-us/dotnet/api/digi.core.interfaces.iserializableobject 'DiGi\.Core\.Interfaces\.ISerializableObject')\.
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection') used to communicate with the database\.
`serializableObjects` [System\.Collections\.Generic\.IEnumerable<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[USerializableObject](DiGi.PostgreSQL.PartitionUniqueReference.md#DiGi.PostgreSQL.PartitionUniqueReference.Modify.UpdateAsync_USerializableObject_(thisNpgsql.NpgsqlConnection,System.Collections.Generic.IEnumerable_USerializableObject_,System.Func_string,DiGi.PostgreSQL.Enums.DataType_,object,DiGi.PostgreSQL.PartitionUniqueReference.Delegates.PartitionUniqueReferenceGeneratingEventHandler).USerializableObject 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Modify\.UpdateAsync\\(this Npgsql\.NpgsqlConnection, System\.Collections\.Generic\.IEnumerable\, System\.Func\, object, DiGi\.PostgreSQL\.PartitionUniqueReference\.Delegates\.PartitionUniqueReferenceGeneratingEventHandler\)\.USerializableObject')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')
A collection of objects that are to be updated in the database\.
`dataTypeFunc` [System\.Func<](https://learn.microsoft.com/en-us/dotnet/api/system.func-2 'System\.Func\`2')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[,](https://learn.microsoft.com/en-us/dotnet/api/system.func-2 'System\.Func\`2')[DiGi\.PostgreSQL\.Enums\.DataType](https://learn.microsoft.com/en-us/dotnet/api/digi.postgresql.enums.datatype 'DiGi\.PostgreSQL\.Enums\.DataType')[>](https://learn.microsoft.com/en-us/dotnet/api/system.func-2 'System\.Func\`2')
A function used to determine the [DiGi\.PostgreSQL\.Enums\.DataType](https://learn.microsoft.com/en-us/dotnet/api/digi.postgresql.enums.datatype 'DiGi\.PostgreSQL\.Enums\.DataType') based on a provided string key\.
`sender` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object')
The object that initiated the request; defaults to null\.
`partitionUniqueReferenceGeneratingEventHandler` [PartitionUniqueReferenceGeneratingEventHandler\(object, PartitionUniqueReferenceGeneratingEventArgs\)](DiGi.PostgreSQL.PartitionUniqueReference.Delegates.md#DiGi.PostgreSQL.PartitionUniqueReference.Delegates.PartitionUniqueReferenceGeneratingEventHandler(object,DiGi.PostgreSQL.PartitionUniqueReference.Classes.PartitionUniqueReferenceGeneratingEventArgs) 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Delegates\.PartitionUniqueReferenceGeneratingEventHandler\(object, DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.PartitionUniqueReferenceGeneratingEventArgs\)')
An optional event handler for generating partition unique references; defaults to null\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.HashSet<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[PartitionUniqueReference](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.PartitionUniqueReference 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.PartitionUniqueReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task representing the asynchronous operation\. The task result contains a [System\.Collections\.Generic\.HashSet<>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1') of updated [PartitionUniqueReference](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.PartitionUniqueReference 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.PartitionUniqueReference') objects, or null if the connection is null, serializable objects are null, or critical table creation fails\.
## Modify\.UpdateTypeIdAsync\(this NpgsqlConnection, string\) Method
Updates or creates a type ID based on the provided name\.
```csharp
public static System.Threading.Tasks.Task UpdateTypeIdAsync(this Npgsql.NpgsqlConnection? npgsqlConnection, string? name);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The PostgreSQL connection instance used to perform the operation\.
`name` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')
The name of the type to update or create\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task that represents the asynchronous operation, containing the updated or created [Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type') object, or null if the operation failed or inputs were invalid\.
## Query Class
```csharp
public static class Query
```
Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → Query
### Methods
## Query\.ContainsAsync\(this NpgsqlConnection, Partition, IEnumerable\\) Method
Checks for the existence of multiple unique references within a specific database partition\.
```csharp
public static System.Threading.Tasks.Task?> ContainsAsync(this Npgsql.NpgsqlConnection npgsqlConnection, DiGi.PostgreSQL.Classes.Partition? partition, System.Collections.Generic.IEnumerable? uniqueReferences);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The PostgreSQL connection instance\.
`partition` [DiGi\.PostgreSQL\.Classes\.Partition](https://learn.microsoft.com/en-us/dotnet/api/digi.postgresql.classes.partition 'DiGi\.PostgreSQL\.Classes\.Partition')
The partition to search within\.
`uniqueReferences` [System\.Collections\.Generic\.IEnumerable<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[DiGi\.Core\.Interfaces\.IUniqueReference](https://learn.microsoft.com/en-us/dotnet/api/digi.core.interfaces.iuniquereference 'DiGi\.Core\.Interfaces\.IUniqueReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')
A collection of unique references to verify\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.HashSet<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[DiGi\.Core\.Interfaces\.IUniqueReference](https://learn.microsoft.com/en-us/dotnet/api/digi.core.interfaces.iuniquereference 'DiGi\.Core\.Interfaces\.IUniqueReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task that represents the asynchronous operation, containing a set of existing unique references, or null if any input is null\.
## Query\.ContainsAsync\(this NpgsqlConnection, Type\) Method
Checks whether a specific database type exists across all supported data type tables\.
```csharp
public static System.Threading.Tasks.Task ContainsAsync(this Npgsql.NpgsqlConnection npgsqlConnection, DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type? type);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The PostgreSQL connection instance\.
`type` [Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type')
The database type to check for existence\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task that represents the asynchronous operation, containing true if the type is found; otherwise, false\.
## Query\.ContainsAsync\(this NpgsqlConnection, IEnumerable\\) Method
Checks for the existence of a collection of partition unique references within the database\.
```csharp
public static System.Threading.Tasks.Task?> ContainsAsync(this Npgsql.NpgsqlConnection npgsqlConnection, System.Collections.Generic.IEnumerable partitionUniqueReferences);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The PostgreSQL connection instance\.
`partitionUniqueReferences` [System\.Collections\.Generic\.IEnumerable<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[PartitionUniqueReference](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.PartitionUniqueReference 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.PartitionUniqueReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')
A collection of partition unique references to verify\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.HashSet<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[PartitionUniqueReference](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.PartitionUniqueReference 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.PartitionUniqueReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task that represents the asynchronous operation, containing a set of existing partition unique references, or null if the input is invalid\.
## Query\.ContainsAsync\(this NpgsqlConnection, Type\) Method
Checks whether a specific system type exists within the database\.
```csharp
public static System.Threading.Tasks.Task ContainsAsync(this Npgsql.NpgsqlConnection npgsqlConnection, System.Type? type);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The PostgreSQL connection instance\.
`type` [System\.Type](https://learn.microsoft.com/en-us/dotnet/api/system.type 'System\.Type')
The system type to check for existence\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task that represents the asynchronous operation, containing true if the type is found; otherwise, false\.
## Query\.SerializableObjectsAsync\\(NpgsqlConnection, IEnumerable\\) Method
Asynchronously retrieves a list of serializable objects based on the provided PostgreSQL connection and partition unique references\.
```csharp
public static System.Threading.Tasks.Task?> SerializableObjectsAsync(Npgsql.NpgsqlConnection? npgsqlConnection, System.Collections.Generic.IEnumerable partitionUniqueReferences)
where USerializableObject : DiGi.Core.Interfaces.ISerializableObject;
```
#### Type parameters
`USerializableObject`
The type of serializable object to retrieve, which must implement ISerializableObject\.
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The Npgsql connection used to execute the query\.
`partitionUniqueReferences` [System\.Collections\.Generic\.IEnumerable<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[PartitionUniqueReference](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.PartitionUniqueReference 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.PartitionUniqueReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')
A collection of partition unique references to filter the objects\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.List<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[USerializableObject](DiGi.PostgreSQL.PartitionUniqueReference.md#DiGi.PostgreSQL.PartitionUniqueReference.Query.SerializableObjectsAsync_USerializableObject_(Npgsql.NpgsqlConnection,System.Collections.Generic.IEnumerable_DiGi.PostgreSQL.PartitionUniqueReference.Classes.PartitionUniqueReference_).USerializableObject 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Query\.SerializableObjectsAsync\\(Npgsql\.NpgsqlConnection, System\.Collections\.Generic\.IEnumerable\\)\.USerializableObject')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task that represents the asynchronous operation, containing a list of serializable objects if successful; otherwise, null\.
## Query\.TypeAsync\(this NpgsqlConnection, string\) Method
Asynchronously retrieves a type from the database by its name\.
```csharp
public static System.Threading.Tasks.Task TypeAsync(this Npgsql.NpgsqlConnection? npgsqlConnection, string? name);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The connection to the PostgreSQL database\.
`name` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')
The name of the type to retrieve\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A [Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type') instance if the type is found; otherwise, `null`\.
## Query\.TypeIdAsync\(this NpgsqlConnection, Type\) Method
Asynchronously retrieves the unique identifier of a type from the database based on its full name\.
```csharp
public static System.Threading.Tasks.Task> TypeIdAsync(this Npgsql.NpgsqlConnection? npgsqlConnection, System.Type? type);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The Npgsql connection used to execute the query\.
`type` [System\.Type](https://learn.microsoft.com/en-us/dotnet/api/system.type 'System\.Type')
The system type for which the ID is being retrieved\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Nullable<](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1')[System\.Int16](https://learn.microsoft.com/en-us/dotnet/api/system.int16 'System\.Int16')[>](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task that represents the asynchronous operation\. The task result contains the type identifier as a short if found; otherwise, null\.
## Query\.TypesAsync\(this NpgsqlConnection, string\) Method
Asynchronously retrieves a list of types from the database based on the provided type name\.
```csharp
public static System.Threading.Tasks.Task?> TypesAsync(this Npgsql.NpgsqlConnection? npgsqlConnection, string? name);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The Npgsql connection to use for the query\.
`name` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')
The name of the type to search for\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.List<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task that represents the asynchronous operation\. The task result contains a list of matching [Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type') objects, or null if the connection is null or the name is invalid\.
## Query\.TypesAsync\(this NpgsqlConnection, IEnumerable\\) Method
Asynchronously retrieves a list of types from the database filtered by a collection of type identifiers\.
```csharp
public static System.Threading.Tasks.Task?> TypesAsync(this Npgsql.NpgsqlConnection? npgsqlConnection, System.Collections.Generic.IEnumerable? typeIds=null);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The Npgsql connection to use for the query\.
`typeIds` [System\.Collections\.Generic\.IEnumerable<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[System\.Int16](https://learn.microsoft.com/en-us/dotnet/api/system.int16 'System\.Int16')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')
An optional collection of short integers representing the IDs of the types to retrieve\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.List<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task that represents the asynchronous operation\. The task result contains a list of matching [Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type') objects, or null if the connection is null\.
## Query\.TypesAsync\(this NpgsqlConnection, Type\) Method
Asynchronously retrieves a list of types from the database that are assignable from the specified type\.
```csharp
public static System.Threading.Tasks.Task?> TypesAsync(this Npgsql.NpgsqlConnection? npgsqlConnection, System.Type? type);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The Npgsql connection to use for the query\.
`type` [System\.Type](https://learn.microsoft.com/en-us/dotnet/api/system.type 'System\.Type')
The system type used to filter the retrieved types\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.List<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A task that represents the asynchronous operation\. The task result contains a list of matching [Type](DiGi.PostgreSQL.PartitionUniqueReference.Classes.md#DiGi.PostgreSQL.PartitionUniqueReference.Classes.Type 'DiGi\.PostgreSQL\.PartitionUniqueReference\.Classes\.Type') objects, or null if the connection or type is null\.
## Query\.UniqueTypeIdsAsync\(this NpgsqlConnection, Partition\) Method
Retrieves all unique type IDs present in a specific partition from the database\.
```csharp
public static System.Threading.Tasks.Task?> UniqueTypeIdsAsync(this Npgsql.NpgsqlConnection? npgsqlConnection, DiGi.PostgreSQL.Classes.Partition? partition);
```
#### Parameters
`npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection')
The Npgsql connection used to execute the query\.
`partition` [DiGi\.PostgreSQL\.Classes\.Partition](https://learn.microsoft.com/en-us/dotnet/api/digi.postgresql.classes.partition 'DiGi\.PostgreSQL\.Classes\.Partition')
The partition for which to retrieve the unique type IDs\.
#### Returns
[System\.Threading\.Tasks\.Task<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Collections\.Generic\.HashSet<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[System\.Int16](https://learn.microsoft.com/en-us/dotnet/api/system.int16 'System\.Int16')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')
A [System\.Collections\.Generic\.HashSet<>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1') containing the unique type IDs if successful; otherwise, `null`\.