Interface IProductDataRetriever<TProductIdentifier, TProductData>
Defines a contract for retrieving product data for price calculations based on product identifiers.
This generic interface can be implemented for different product identifier and product data types. Its responsibilities include:
- Building and executing queries against the database using product identifiers.
- Mapping raw product data into strongly typed
TProductDataobjects. - Returning results as a read-only dictionary keyed by
TProductIdentifier.
public interface IProductDataRetriever<TProductIdentifier, TProductData> where TProductIdentifier : ProductIdentifier where TProductData : ProductData
Type Parameters
TProductIdentifierThe type representing the product identifier. This can be a simple ProductIdentifier for standalone products, or a derived type that also carries additional information, such as a variant identifier.
TProductDataThe type representing the product data returned from the database. Must inherit from ProductData and typically contains pricing, availability, and localized content information for the product or its variant.
- Extension Methods
Methods
Get(IEnumerable<TProductIdentifier>, string, CancellationToken)
Retrieves product data for the specified product identifiers.
Task<IReadOnlyDictionary<TProductIdentifier, TProductData>> Get(IEnumerable<TProductIdentifier> productIdentifiers, string languageName, CancellationToken cancellationToken = default)
Parameters
productIdentifiersIEnumerable<TProductIdentifier>A collection of product identifiers to query.
languageNamestringThe content language in which the product data should be retrieved.
cancellationTokenCancellationTokenA token that can be used to cancel the asynchronous operation.
Returns
- Task<IReadOnlyDictionary<TProductIdentifier, TProductData>>
A read-only dictionary that maps each
TProductIdentifierto its correspondingTProductData.