AdvantageCMS.Core.Common.BaseClasses Namespace
Build With Advantage

IDataTranslateCommand Interface

Optional interface that allows an entity to translate or redirect a command name before the data access layer executes it. Useful when multiple logical operations should map to the same stored procedure, or when a command name needs to be dynamically resolved at runtime.

Namespace:  AdvantageCMS.Data.Interfaces
Assembly:  AdvantageCMS.Data (in AdvantageCMS.Data.dll)

Syntax


public interface IDataTranslateCommand

Remarks


If no translation is needed, return the commandName unchanged. This interface is checked by the data access layer before execution — if the entity implements it, the translated command name is used instead of the original.

Examples


C#
public class CustomerData : IDataAccessable, IDataTranslateCommand
{
    public bool UseArchiveDatabase { get; set; }

    public string GetCommandToExecute(string commandName)
    {
        // Redirect reads to the archive procedure when flagged
        if (commandName == "Customer_GetByID" && UseArchiveDatabase)
            return "CustomerArchive_GetByID";

        return commandName;
    }

    // ... IDataAccessable members ...
}