Struct DynamicRelationCalculationResult
- Namespace
- Dynamicweb.Ecommerce.Products.DynamicRelations
- Assembly
- Dynamicweb.Ecommerce.dll
Represents the calculated output based on a specific DynamicRelationCalculationConfiguration
public readonly record struct DynamicRelationCalculationResult : IEquatable<DynamicRelationCalculationResult>
- Implements
- Inherited Members
Constructors
DynamicRelationCalculationResult(IEnumerable<DynamicRelationCalculation>, bool, string?, string?)
Represents the calculated output based on a specific DynamicRelationCalculationConfiguration
public DynamicRelationCalculationResult(IEnumerable<DynamicRelationCalculation> Items, bool IsSuccess, string? ErrorMessage = null, string? DetailedErrorMessage = null)
Parameters
ItemsIEnumerable<DynamicRelationCalculation>The resulting calculations, if any.
IsSuccessboolIndicates whether the calculation was successful.
ErrorMessagestringAn optional error message if the calculation failed.
DetailedErrorMessagestringAn optional detailed error message for debugging purposes.
Properties
DetailedErrorMessage
An optional detailed error message for debugging purposes.
public string? DetailedErrorMessage { get; init; }
Property Value
ErrorMessage
An optional error message if the calculation failed.
public string? ErrorMessage { get; init; }
Property Value
IsSuccess
Indicates whether the calculation was successful.
public bool IsSuccess { get; init; }
Property Value
Items
The resulting calculations, if any.
public IEnumerable<DynamicRelationCalculation> Items { get; init; }
Property Value
Methods
Failure(string, string?)
Creates a failed calculation result with an error message.
public static DynamicRelationCalculationResult Failure(string message, string? detailedMessage = null)
Parameters
messagestringThe error message describing why the calculation failed.
detailedMessagestringAn optional detailed error message for debugging purposes.
Returns
- DynamicRelationCalculationResult
A DynamicRelationCalculationResult indicating failed execution.
Exceptions
- ArgumentException
Thrown when
messageis null or whitespace.
Proceed()
Creates a successful calculation result with no calculated relations. This method is typically used for intermediate pipeline steps that succeed but don't produce calculations themselves.
public static DynamicRelationCalculationResult Proceed()
Returns
- DynamicRelationCalculationResult
A DynamicRelationCalculationResult indicating successful execution with an empty collection of calculations.
Remarks
This method is distinct from Success(IEnumerable<DynamicRelationCalculation>) to provide clarity about intent:
- Use this parameterless method when a step completes successfully but produces no calculations (e.g., validation, preparation steps)
- Use the overload with parameters when a step produces actual calculation results (e.g., aggregation, computation steps)
Both methods result in the same outcome when no calculations are produced, but this method makes the developer's intent explicit and improves code readability in pipeline steps that focus on setup or validation rather than calculation.
Success(IEnumerable<DynamicRelationCalculation>)
Creates a successful calculation result with the specified calculated relations. This overload is used when a calculation step produces actual dynamic relation calculations.
public static DynamicRelationCalculationResult Success(IEnumerable<DynamicRelationCalculation> items)
Parameters
itemsIEnumerable<DynamicRelationCalculation>The calculated dynamic relations produced by the operation. Cannot be null, but may be an empty collection if no calculations were produced.
Returns
- DynamicRelationCalculationResult
A DynamicRelationCalculationResult indicating successful execution with the provided calculations.
Remarks
This method is used when a calculation step successfully produces DynamicRelationCalculation objects. It is distinct from Proceed() which is intended for steps that succeed without producing calculations.
Each DynamicRelationCalculation in the collection represents a computed relationship between products, typically containing calculated field values, source/target product information, and metadata about the calculation.
Common usage scenarios:
- Aggregation steps that compute summary values across product groups
- Field calculation steps that derive new values from existing product data
- Final pipeline steps that produce the complete set of dynamic relations
If you have no calculations to return, prefer using Proceed() to make the intent clear rather than passing an empty collection to this method.
Exceptions
- ArgumentNullException
Thrown when
itemsis null.