2025-09-30 17:03:39 +02:00

30 lines
1.3 KiB
C#

#if NET
using System.Text.Json.Serialization;
namespace DigitalData.Core.Abstraction.Application.DTO;
/// <summary>
/// Represents a result of an operation that includes data, inheriting from <see cref="Result"/>.
/// </summary>
/// <typeparam name="T">The type of the data included in the result.</typeparam>
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public class DataResult<T> : Result
{
/// <summary>
/// Gets or sets the data included in the result. This property is required.
/// It will be ignored during JSON serialization if the value is null.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public required T Data { get; set; }
/// <summary>
/// Converts the current <see cref="DataResult{T}"/> to a failed <see cref="DataResult{I}"/>,
/// preserving the messages and notices.
/// </summary>
/// <typeparam name="I">The type of the data in the new failed result.</typeparam>
/// <returns>A failed <see cref="DataResult{I}"/> with the current messages and notices.</returns>
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public DataResult<I> ToFail<I>() => Fail<I>().Message(Messages).Notice(Notices);
}
#endif