Example #1
0
        /// <summary>
        /// 获取类的创建语句
        /// </summary>
        /// <param name="type"></param>
        private void GetClassSQL()
        {
            _lstSql = new List <string>();
            List <KeyWordTableParamItem> lstTable = new List <KeyWordTableParamItem>();
            DBConfigInfo dbcinfo = FrmDBSetting.GetDBConfigInfo(DesignerInfo, "DataAccess.");
            DBInfo       dbInfo  = dbcinfo.CreateDBInfo();

            foreach (ClrClass curType in SelectedClass)
            {
                EntityConfig entity = new EntityConfig(curType, DesignerInfo);

                if (string.IsNullOrEmpty(entity.TableName) || !entity.IsTable)
                {
                    continue;
                }
                string typeName = null;
                Stack <EntityConfig>          stkConfig   = EntityConfig.GetEntity(entity, DesignerInfo);
                List <EntityParam>            lstParam    = new List <EntityParam>();
                List <TableRelationAttribute> lstRelation = new List <TableRelationAttribute>();
                string lastTableName = null;
                string lastSummary   = null;
                while (stkConfig.Count > 0)
                {
                    EntityConfig centity = stkConfig.Pop();
                    FillParams(centity, lstParam, lstRelation);
                    lastTableName = centity.TableName;
                    lastSummary   = centity.Summary;
                }
                KeyWordTableParamItem table = new KeyWordTableParamItem(lstParam, lstRelation, lastTableName, null);
                table.Description = lastSummary;
                lstTable.Add(table);
            }
            try
            {
                using (BatchAction ba = dbInfo.DefaultOperate.StarBatchAction())
                {
                    _lstSql = TableChecker.CheckTable(dbInfo, lstTable);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("生成语句失败:" + ex.Message);
            }
            ShowSql();
        }