Class ItemStore
Implements
Inherited Members
Namespace: DataWeb.Structure.SqlServer
Assembly: DataWeb.Data.SqlServer.dll
Syntax
public class ItemStore : IItemStore
Constructors
ItemStore(ISqlHelper, TimeProvider)
Declaration
public ItemStore(ISqlHelper sqlHelper, TimeProvider timeProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| ISqlHelper | sqlHelper | |
| TimeProvider | timeProvider |
Properties
Name
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
DeleteInactiveVersionAsync(string, Section, string, CancellationToken)
Sets Deleted status for an inactive version.
Declaration
public Task DeleteInactiveVersionAsync(string itemIdMaster, Section section, string versionName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The IdMaster of the item. |
| Section | section | The Section of the item. |
| string | versionName | The name of the version. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
DeleteMasterPartAsync(string, CancellationToken)
Deletes the master metadata for an item.
Declaration
public Task DeleteMasterPartAsync(string itemIdMaster, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item to delete. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
DeleteSectionPartsAsync(string, string, string, CancellationToken)
Deletes one or all section parts for an item from the specified section table.
Declaration
public Task DeleteSectionPartsAsync(string itemIdMaster, string sectionTableName, string sectionPartId = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| string | sectionTableName | The table name where section data is stored. Must not be a system table. |
| string | sectionPartId | The ID of the specific section part to delete, or null to delete all parts for the item. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster or sectionTableName is null or empty, or when sectionTableName is a system table. |
DisableCultureVersionsAsync(string, Section, CancellationToken)
Disables all versions for a specific culture/localization, setting them to inactive status.
Declaration
public Task DisableCultureVersionsAsync(string itemIdMaster, Section section, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
| ArgumentNullException | Thrown when section is null. |
DisableGlobalVersionsAsync(string, Section, CancellationToken)
Disables all global versions (VersionCulture = 'Global') for an item, setting them to inactive status.
Declaration
public Task DisableGlobalVersionsAsync(string itemIdMaster, Section section, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
| ArgumentNullException | Thrown when section is null. |
GetDateModifiedAsync(string, CancellationToken)
Retrieves the last modification timestamp of an item.
Declaration
public Task<DateTimeOffset?> GetDateModifiedAsync(string itemIdMaster, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<DateTimeOffset?> | The DateTimeOffset of the last modification, or null if the item is not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
GetItemVersionAsync(string, Section, VersionFilter, CancellationToken)
Retrieves a single item version matching the specified filter criteria.
Declaration
public Task<ItemVersion> GetItemVersionAsync(string itemIdMaster, Section section, VersionFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| VersionFilter | filter | The filter criteria to apply when retrieving the version. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<ItemVersion> | The first ItemVersion matching the filter, or null if no match found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
| ArgumentNullException | Thrown when section or filter is null. |
GetItemVersionLocalizationsAsync(string, Section, CancellationToken)
Retrieves all localization cultures available for an item in a specific section.
Declaration
public Task<IEnumerable<string>> GetItemVersionLocalizationsAsync(string itemIdMaster, Section section, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<string>> | A collection of culture strings (e.g., 'en-US', 'it-IT', 'Global'). |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
| ArgumentNullException | Thrown when section is null. |
GetItemVersionPreviewCountAsync(string, Section, CancellationToken)
Retrieves the count of preview versions for an item in a specific section.
Declaration
public Task<long> GetItemVersionPreviewCountAsync(string itemIdMaster, Section section, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<long> | The number of preview versions found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
| ArgumentNullException | Thrown when section is null. |
GetItemVersionsAsync(string, Section, VersionFilter, CancellationToken)
Retrieves all versions of an item in a specific section filtered by criteria.
Declaration
public Task<IEnumerable<ItemVersion>> GetItemVersionsAsync(string itemIdMaster, Section section, VersionFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| VersionFilter | filter | The filter criteria (name, culture, status, default flag, history flag). |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<ItemVersion>> | A collection of ItemVersion objects matching the filter criteria. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
| ArgumentNullException | Thrown when section or filter is null. |
GetMasterPartAsync(string, CancellationToken)
Retrieves the master part metadata for a specific item.
Declaration
public Task<Item.MasterPart> GetMasterPartAsync(string itemIdMaster, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<Item.MasterPart> | The master part containing label, status, completion flag, and timestamps, or null if not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
GetNewHistoryVersionNameAsync(string, string, Section, CancellationToken)
Generates the next sequential history version name (child version) for a given parent version.
Declaration
public Task<string> GetNewHistoryVersionNameAsync(string itemIdMaster, string parentVersionName, Section section, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| string | parentVersionName | The name of the parent version to create history from. |
| Section | section | The section containing storage and metadata information. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<string> | The next history version name in format 'ParentName-01', 'ParentName-02', etc. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster or parentVersionName is null or empty. |
| ArgumentNullException | Thrown when section is null. |
GetNewVersionNameAsync(string, Section, CancellationToken)
Generates the next sequential version name for an item.
Declaration
public Task<string> GetNewVersionNameAsync(string itemIdMaster, Section section, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<string> | The next version name in format '01', '02', etc. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
| ArgumentNullException | Thrown when section is null. |
GetParentVersionName(string)
Gets the parent version name for a given history version name.
Declaration
public string GetParentVersionName(string historyVersionName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | historyVersionName | The history version name. |
Returns
| Type | Description |
|---|---|
| string | The parent version name. |
GetSectionPartAsync(string, Section, string, string, CancellationToken)
Retrieves the section-specific data for a version of an item.
Declaration
public Task<Item.SectionPart> GetSectionPartAsync(string itemIdMaster, Section section, string versionCulture, string versionName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| string | versionCulture | The culture/localization of the version. |
| string | versionName | The name of the version, or null to get the active/live version. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<Item.SectionPart> | The section part containing versioning metadata and section-specific data fields, or null if not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
| ArgumentNullException | Thrown when section is null. |
SetLabelAsync(string, string, CancellationToken)
Updates the display label of an item.
Declaration
public Task SetLabelAsync(string itemIdMaster, string label, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| string | label | The new label text. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster or label is null or empty. |
SetMasterPartAsync(MasterPart, CancellationToken)
Creates or updates the master part metadata for an item.
Declaration
public Task<string> SetMasterPartAsync(Item.MasterPart masterPart, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Item.MasterPart | masterPart | The master part data to save (must contain IdMaster, Label, Status, and other metadata). |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<string> | The item ID of the created or updated master. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when masterPart is null. |
| ArgumentException | Thrown when masterPart.IdMaster is null or empty. |
SetSectionPartAsync(SectionPart, string, CancellationToken)
Saves section-specific data for a version of an item.
Declaration
public Task SetSectionPartAsync(Item.SectionPart sectionPart, string sectionTableName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Item.SectionPart | sectionPart | The section data to save (contains item ID, version info, and custom fields). |
| string | sectionTableName | The table name where section data is stored. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when sectionPart is null. |
| ArgumentException | Thrown when sectionTableName is null or empty. |
SetStatusAsync(string, ItemStatus, CancellationToken)
Updates the status of an item (Active, Inactive, Deleted, etc.).
Declaration
public Task SetStatusAsync(string itemIdMaster, ItemStatus status, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| ItemStatus | status | The new status value. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
SetVersionAsDefaultAsync(string, Section, ItemVersion, CancellationToken)
Marks a specific version as the default version (IsVersionDefault = true) for ordering and retrieval.
Declaration
public Task SetVersionAsDefaultAsync(string itemIdMaster, Section section, ItemVersion version, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| ItemVersion | version | The version to set as default. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |
| ArgumentNullException | Thrown when section or version is null. |
SetVersionAsDefaultByCultureAsync(string, Section, string, CancellationToken)
Sets a version as the default for a specific culture/localization.
Declaration
public Task SetVersionAsDefaultByCultureAsync(string itemIdMaster, Section section, string versionCulture, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| string | versionCulture | The culture/localization to set as default. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster or versionCulture is null or empty. |
| ArgumentNullException | Thrown when section is null. |
SetVersionLinkedValuesAsync(string, Section, string, Dictionary<string, object>, CancellationToken)
Updates field values for related versions (linked versions) in an item.
Declaration
public Task SetVersionLinkedValuesAsync(string itemIdMaster, Section section, string versionName, Dictionary<string, object> linkedValues, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| string | versionName | The source version name to propagate updates from. |
| Dictionary<string, object> | linkedValues | Dictionary of field names and values to update in related versions. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster or versionName is null or empty. |
| ArgumentNullException | Thrown when section or linkedValues is null. |
SetVersionStatusAndCultureAsync(string, Section, string, string, VersionStatus, IEnumerable<string>, CancellationToken)
Updates the status and culture of a version, with synchronized updates across related versions.
Declaration
public Task<VersionUpdateResult> SetVersionStatusAndCultureAsync(string itemIdMaster, Section section, string versionName, string versionCulture, VersionStatus versionStatus, IEnumerable<string> cultures, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| Section | section | The section containing storage and metadata information. |
| string | versionName | The name of the version to update. |
| string | versionCulture | The culture/localization to apply. |
| VersionStatus | versionStatus | The new status (Active, Live, Preview, Inactive, Deleted). |
| IEnumerable<string> | cultures | All available cultures for ordering and validation. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<VersionUpdateResult> | A VersionUpdateResult containing success status and any error code if operation failed. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster, versionName, or versionCulture is null or empty. |
| ArgumentNullException | Thrown when section or cultures is null. |
UpdateDateModifiedAsync(string, CancellationToken)
Updates the last modification timestamp of an item to the current time.
Declaration
public Task UpdateDateModifiedAsync(string itemIdMaster, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | itemIdMaster | The unique identifier of the master item. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when itemIdMaster is null or empty. |