Ejemplo n.º 1
0
        public static string CreateColSql(AtomDbColumnModel model, AtomDbTable tb)
        {
            var sql     = new StringBuilder();
            var nullSql = model.IsPrimary || !model.IsNull ? "NOT NULL"  : "NULL";
            var idsql   = model.IsIdentity && (model.DbType.ToLower() == "int" || model.DbType.ToLower() == "bigint") ? "IDENTITY (1,1)" : "";
            var desc    = model.Name + "^" + model.Desc;

            sql.AppendLine($@"ALTER TABLE [{tb.DbTableName}] ADD [{model.DbColumnName}] {model.DbType} {nullSql} {idsql};");
            if (model.IsPrimary)
            {
                sql.AppendLine($@" ALTER TABLE [{tb.DbTableName}] ADD constraint  [PK_{tb.Name}] PRIMARY KEY({model.DbColumnName}) ;");
            }
            sql.AppendLine($@"EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{desc}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'{tb.DbTableName}', @level2type=N'COLUMN',@level2name=N'{model.DbColumnName}'");

            return(sql.ToString());
        }
Ejemplo n.º 2
0
 public List <AtomDbColumnModel> Columns(AtomDbColumnModel model)
 {
     return(rep.Columns(model));
 }
Ejemplo n.º 3
0
        public Br <long> AddColumn([FromBody] AtomDbColumnModel model)
        {
            var res = starter.AddColumn(model);

            return(new Br <long>(res));
        }
Ejemplo n.º 4
0
 public long AddColumn(AtomDbColumnModel model)
 {
     return(rep.AddColumn(model));
 }
Ejemplo n.º 5
0
        public Br <List <AtomDbColumnModel> > Columns([FromBody] AtomDbColumnModel model)
        {
            var res = starter.Columns(model);

            return(new Br <List <AtomDbColumnModel> >(res));
        }