Using nested class from single db table?

I have a DTO defined that maps to a single db table; simplified below:

[Schema("Account")]
[DataContract]
public class Cost : AuditBase
{
    [AutoId]
    [DataMember] public Guid Id { get; set; } = Guid.Empty;

    [DataMember] public string Name { get; set; } = string.Empty;
    
    // Either both null or both non-null
    [DataMember] public decimal? Amount { get; set; } = null;
    [DataMember] public string? AlphaCode { get; set; } = null;
}

For various application reasons, I am considering a nested class to replace the Amount/AlphaCode pair above. For example:

public class FxAmount
{
    // Neither property may be null
    [DataMember] public decimal? Amount { get; set; } = null;
    [DataMember] public string? AlphaCode { get; set; } = null;
}

[Schema("Account")]
[DataContract]
public class Cost : AuditBase
{
    [AutoId]
    [DataMember] public Guid Id { get; set; } = Guid.Empty;
    [DataMember] public string Name { get; set; } = string.Empty;

    [DataMember] public FxAmount? FxAmount { get; set; } = null;
}

The aim is to avoid the potential risk of an incorrect FxAmount pair (i.e. an Amount being specified without an AlphaCode). This is already validated at the db level using check constraints, but I would like the application code to make the illegal state unrepresentable.

My problem is understanding how to define the above, such that the properties from the nested class, FxAmount, are correctly loaded/saved to the corresponding columns in the Account.Cost table.

I was unable to find any examples (a bad sign?), so I would be grateful for any suggestions.

AutoQuery mapping doesn’t support mapping from nested classes, you could create your own custom service that internally maps to an AutoQuery DTO and execute the IAutoQuery APIs in your custom implementation.

Thank you for answering, it seems like a sensible approach. My other consideration would be to use ServiceStack’s Validation techniques, which might make more sense in the long run.