#### [DiGi\.PostgreSQL\.PartitionReference](DiGi.PostgreSQL.PartitionReference.Overview.md 'DiGi\.PostgreSQL\.PartitionReference\.Overview') ## DiGi\.PostgreSQL\.PartitionReference 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\.RemoveAsync\(NpgsqlConnection, IEnumerable\\) Method Asynchronously removes the specified partition references from the database\. ```csharp public static System.Threading.Tasks.Task?> RemoveAsync(Npgsql.NpgsqlConnection? npgsqlConnection, System.Collections.Generic.IEnumerable partitionReferences); ``` #### Parameters `npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection') The Npgsql connection to be used for the operation\. `partitionReferences` [System\.Collections\.Generic\.IEnumerable<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[PartitionReference](DiGi.PostgreSQL.PartitionReference.Classes.md#DiGi.PostgreSQL.PartitionReference.Classes.PartitionReference 'DiGi\.PostgreSQL\.PartitionReference\.Classes\.PartitionReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1') The collection of partition references to remove\. #### 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')[PartitionReference](DiGi.PostgreSQL.PartitionReference.Classes.md#DiGi.PostgreSQL.PartitionReference.Classes.PartitionReference 'DiGi\.PostgreSQL\.PartitionReference\.Classes\.PartitionReference')[>](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 hash set containing the successfully removed partition references, or null if the connection is null or an error occurred during processing\. ## Modify\.UpdateAsync\\(this NpgsqlConnection, IEnumerable\, Func\, object, PartitionReferenceGeneratingEventHandler\) Method Asynchronously updates the specified serializable objects in the PostgreSQL database, utilizing partitions and UPSERT logic\. ```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.PartitionReference.Delegates.PartitionReferenceGeneratingEventHandler? partitionReferenceGeneratingEventHandler=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 connection to be used for the database operation\. `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.PartitionReference.md#DiGi.PostgreSQL.PartitionReference.Modify.UpdateAsync_USerializableObject_(thisNpgsql.NpgsqlConnection,System.Collections.Generic.IEnumerable_USerializableObject_,System.Func_string,DiGi.PostgreSQL.Enums.DataType_,object,DiGi.PostgreSQL.PartitionReference.Delegates.PartitionReferenceGeneratingEventHandler).USerializableObject 'DiGi\.PostgreSQL\.PartitionReference\.Modify\.UpdateAsync\\(this Npgsql\.NpgsqlConnection, System\.Collections\.Generic\.IEnumerable\, System\.Func\, object, DiGi\.PostgreSQL\.PartitionReference\.Delegates\.PartitionReferenceGeneratingEventHandler\)\.USerializableObject')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1') The collection of objects to be updated\. `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 that determines the [DiGi\.PostgreSQL\.Enums\.DataType](https://learn.microsoft.com/en-us/dotnet/api/digi.postgresql.enums.datatype 'DiGi\.PostgreSQL\.Enums\.DataType') based on the partition name\. `sender` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') The object that sends the event, passed to the [partitionReferenceGeneratingEventHandler](DiGi.PostgreSQL.PartitionReference.md#DiGi.PostgreSQL.PartitionReference.Modify.UpdateAsync_USerializableObject_(thisNpgsql.NpgsqlConnection,System.Collections.Generic.IEnumerable_USerializableObject_,System.Func_string,DiGi.PostgreSQL.Enums.DataType_,object,DiGi.PostgreSQL.PartitionReference.Delegates.PartitionReferenceGeneratingEventHandler).partitionReferenceGeneratingEventHandler 'DiGi\.PostgreSQL\.PartitionReference\.Modify\.UpdateAsync\\(this Npgsql\.NpgsqlConnection, System\.Collections\.Generic\.IEnumerable\, System\.Func\, object, DiGi\.PostgreSQL\.PartitionReference\.Delegates\.PartitionReferenceGeneratingEventHandler\)\.partitionReferenceGeneratingEventHandler')\. `partitionReferenceGeneratingEventHandler` [PartitionReferenceGeneratingEventHandler\(object, PartitionReferenceGeneratingEventArgs\)](DiGi.PostgreSQL.PartitionReference.Delegates.md#DiGi.PostgreSQL.PartitionReference.Delegates.PartitionReferenceGeneratingEventHandler(object,DiGi.PostgreSQL.PartitionReference.Classes.PartitionReferenceGeneratingEventArgs) 'DiGi\.PostgreSQL\.PartitionReference\.Delegates\.PartitionReferenceGeneratingEventHandler\(object, DiGi\.PostgreSQL\.PartitionReference\.Classes\.PartitionReferenceGeneratingEventArgs\)') An optional event handler for generating partition references\. #### 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')[PartitionReference](DiGi.PostgreSQL.PartitionReference.Classes.md#DiGi.PostgreSQL.PartitionReference.Classes.PartitionReference 'DiGi\.PostgreSQL\.PartitionReference\.Classes\.PartitionReference')[>](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\. The task result contains a HashSet of PartitionReference of updated partition references, or null if the connection or objects are null or if the table creation fails\. ## 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, IEnumerable\\) Method Asynchronously checks if the specified partition references exist in the database\. ```csharp public static System.Threading.Tasks.Task?> ContainsAsync(this Npgsql.NpgsqlConnection npgsqlConnection, System.Collections.Generic.IEnumerable? partitionReferences); ``` #### Parameters `npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection') The Npgsql connection to be used for the operation\. `partitionReferences` [System\.Collections\.Generic\.IEnumerable<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[PartitionReference](DiGi.PostgreSQL.PartitionReference.Classes.md#DiGi.PostgreSQL.PartitionReference.Classes.PartitionReference 'DiGi\.PostgreSQL\.PartitionReference\.Classes\.PartitionReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1') The collection of partition references 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\.Collections\.Generic\.HashSet<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[PartitionReference](DiGi.PostgreSQL.PartitionReference.Classes.md#DiGi.PostgreSQL.PartitionReference.Classes.PartitionReference 'DiGi\.PostgreSQL\.PartitionReference\.Classes\.PartitionReference')[>](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\. The task result contains a HashSet of the partition references that exist in the database, or null if the connection or the input collection is null\. ## Query\.SerializableObjectsAsync\\(NpgsqlConnection, string\) Method Asynchronously retrieves a list of serializable objects associated with a specific partition name\. ```csharp public static System.Threading.Tasks.Task?> SerializableObjectsAsync(Npgsql.NpgsqlConnection? npgsqlConnection, string name) where USerializableObject : DiGi.Core.Interfaces.ISerializableObject; ``` #### Type parameters `USerializableObject` The type of the serializable object, which must implement ISerializableObject\. #### Parameters `npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection') The Npgsql connection to use for the database query\. `name` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The name of the partition from which to retrieve 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.PartitionReference.md#DiGi.PostgreSQL.PartitionReference.Query.SerializableObjectsAsync_USerializableObject_(Npgsql.NpgsqlConnection,string).USerializableObject 'DiGi\.PostgreSQL\.PartitionReference\.Query\.SerializableObjectsAsync\\(Npgsql\.NpgsqlConnection, string\)\.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 or null if the connection is null\. ## Query\.SerializableObjectsAsync\\(NpgsqlConnection, IEnumerable\\) Method Asynchronously retrieves a list of serializable objects associated with a collection of partition references\. ```csharp public static System.Threading.Tasks.Task?> SerializableObjectsAsync(Npgsql.NpgsqlConnection? npgsqlConnection, System.Collections.Generic.IEnumerable partitionReferences) where USerializableObject : DiGi.Core.Interfaces.ISerializableObject; ``` #### Type parameters `USerializableObject` The type of the serializable object, which must implement ISerializableObject\. #### Parameters `npgsqlConnection` [Npgsql\.NpgsqlConnection](https://learn.microsoft.com/en-us/dotnet/api/npgsql.npgsqlconnection 'Npgsql\.NpgsqlConnection') The Npgsql connection to use for the database query\. `partitionReferences` [System\.Collections\.Generic\.IEnumerable<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[PartitionReference](DiGi.PostgreSQL.PartitionReference.Classes.md#DiGi.PostgreSQL.PartitionReference.Classes.PartitionReference 'DiGi\.PostgreSQL\.PartitionReference\.Classes\.PartitionReference')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1') A collection of partition references used to identify the objects 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')[USerializableObject](DiGi.PostgreSQL.PartitionReference.md#DiGi.PostgreSQL.PartitionReference.Query.SerializableObjectsAsync_USerializableObject_(Npgsql.NpgsqlConnection,System.Collections.Generic.IEnumerable_DiGi.PostgreSQL.PartitionReference.Classes.PartitionReference_).USerializableObject 'DiGi\.PostgreSQL\.PartitionReference\.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 or null if the connection or partition references are null\.