namespace EnvelopeGenerator.Application.SQL; /// /// Extension method for converting objects to SQL parameter strings. /// public static class ParamsExtensions { /// /// Converts a .NET object to its corresponding SQL-safe parameter string. /// /// The object to convert. /// A string representing the SQL parameter. public static string ToSqlParam(this object? obj) { if (obj is null) return "NULL"; else if (obj is string strVal) return $"'{strVal}'"; else if (obj is bool boolVal) return boolVal ? "1" : "0"; else if (obj is double doubleVal) return $"'{doubleVal}'"; else if (obj is int intVal) return intVal.ToString(); else throw new NotSupportedException($"Type '{obj.GetType().FullName}' is not supported for SQL parameter conversion."); } }