Exemple #1
0
        internal string Definition(SqlSyntax syntax, bool?nullableOverride = null)
        {
            string result = null;

            if (!string.IsNullOrEmpty(Expression))
            {
                result = $"<{Name}> AS {Expression}";
            }
            else
            {
                bool   isNull   = (!nullableOverride.HasValue) ? IsNullable : nullableOverride.Value;
                string identity = (Table.IdentityColumn?.Equals(Name) ?? false) ? $" {syntax.IdentitySyntax}" : string.Empty;
                result = $"<{Name}> {syntax.GetDataTypeDefinition(this)}{identity} {((isNull) ? "NULL" : "NOT NULL")}";
                if (!string.IsNullOrEmpty(Default))
                {
                    result += $" DEFAULT ({Default})";
                }
            }

            return(result);
        }