public virtual IDbColumn BuildColumn(
     DbReference dbRef, string colName, DbValType type, string alias = null, bool isJoinKey = false)
 {
     return(new SqlColumn
     {
         Name = colName,
         Ref = dbRef,
         ValType = type,
         Alias = alias,
         IsJoinKey = isJoinKey,
         OutputOption = OutputOption
     });
 }
        /// <summary>
        /// Add selectable into the selection of the select which referred by the ref column.
        /// If the ref column has a RefTo ref column, this function will also recursively add
        /// the selectable to RefTo ref columns
        /// </summary>
        public static void AddToReferedSelect(
            this IDbRefColumn refCol, IDbObjectFactory factory, string colName, DbValType colType, string alias = null)
        {
            if (refCol.RefTo != null)
            {
                refCol.RefTo.AddToReferedSelect(factory, colName, colType, alias);
                colName = alias ?? colName;
            }

            var column    = factory.BuildColumn(refCol.Ref, colName, colType, alias);
            var selection = refCol.OwnerSelect.Selection;

            selection.Remove(refCol);
            selection.Add(column);
        }