Пример #1
0
 public void UpdateIdField()
 {
     foreach (var f in Fields)
     {
         if (f.ModifiedFieldName.ToUpper() == ClassName.ToUpper() + "ID")
         {
             f.ModifiedFieldName = "Id";
         }
     }
 }
Пример #2
0
        public string CreateDbStr()
        {
            var tablename = ClassName.ToUpper();
            var result    = $"drop table {tablename}\r\ncreate table {tablename}\r\n(\r\n\tId NUMBER(20),\r\n";
            var lst       = Data.Select(n => $"\t{n.EnName} nvarchar2(255),");

            result += string.Join("\r\n", lst);
            result  = result.Substring(0, result.Length - 1);
            result += "\r\n)\r\n";
            result += $"--alter table {tablename} drop constraint PK_{tablename}_ID;\r\n--SELECT * from user_cons_columns c where c.table_name = '{tablename}';\r\nalter table {tablename} add constraint PK_{tablename}_ID primary key(ID);";
            result += $"\r\ndrop SEQUENCE SE_{tablename}ID;\r\nCREATE SEQUENCE SE_{tablename}ID\r\nINCREMENT BY 1 -- 每次加几个\r\nSTART WITH 1 -- 从1开始计数\r\nNOMAXVALUE -- 不设置最大值\r\nNOCYCLE -- 一直累加,不循环\r\nNOCACHE -- 不建缓冲区\r\n";
            result += string.Format("--创建触发器\r\ncreate or replace trigger {0}_AUTOID\r\nbefore insert on {0} for each row\r\nbegin\r\nselect SE_{0}ID.nextval into :new.ID from dual;\r\nend {0}_AUTOID;\r\n\r\n", tablename);
            return(result);
        }