Ejemplo n.º 1
0
        private void CreateCodeClassConfigsBody(IGeneratorWriter scriptWriter, TableDefInfo tableInfo, string blokIndent)
        {
            string tableName = tableInfo.TableName();

            blokIndent = IndentPlus(blokIndent, TAB_INDENT1);

            scriptWriter.WriteCodeLine(blokIndent + "ToTable(\"" + tableName + "\");");

            IList <string> xpkcolList = tableInfo.PrimaryKeyColumnList();

            string keyNames = "";

            foreach (string columnName in xpkcolList)
            {
                string propertyName = columnName.ConvertNameToCamel();

                keyNames += "p." + propertyName + ", ";
            }
            scriptWriter.WriteCodeLine(blokIndent + "HasKey(p => new { " + keyNames.TrimEnd(DBConstants.TRIM_CHARS) + " });");

            IList <TableFieldDefInfo> columnList = tableInfo.TableColumnsForVersion(m_createVersion);

            foreach (TableFieldDefInfo columnInfo in columnList)
            {
                string columnName = ClassColumnName(columnInfo);

                int columnType = columnInfo.m_nType;

                int columnMaxx = columnInfo.DbColumnSize();

                string propertyName = columnName.ConvertNameToCamel();

                scriptWriter.WriteCodeLine(blokIndent + "Property(d => d." + propertyName + ").HasColumnName(\"" + columnName + "\");");
            }
        }
Ejemplo n.º 2
0
        private void CreateCodeClassDefinitionBody(IGeneratorWriter scriptWriter, TableDefInfo tableInfo, string className, string blokIndent)
        {
            scriptWriter.WriteCodeLine(blokIndent + "public " + className + "()");
            scriptWriter.WriteCodeLine(blokIndent + "{");
            scriptWriter.WriteCodeLine(blokIndent + "}");
            scriptWriter.WriteCodeLine("");

            string tableName = tableInfo.TableName();

            IList <TableFieldDefInfo> columnList = tableInfo.TableColumnsForVersion(m_createVersion);

            foreach (TableFieldDefInfo columnInfo in columnList)
            {
                string columnName = ClassColumnName(columnInfo);

                int columnType = columnInfo.m_nType;

                int columnMaxx = columnInfo.DbColumnSize();

                bool columnNull = columnInfo.DbColumnNull();

                string propertyName = columnName.ConvertNameToCamel();

                string propertyType = DBPlatform.EntityConvertDataType(columnType, columnMaxx, !columnNull);

                scriptWriter.WriteCodeLine(blokIndent + "public " + propertyType + " " + propertyName + " { get; set; }");
            }
        }
Ejemplo n.º 3
0
        private string TableColsDefinition(TableDefInfo tableInfo, bool createRels, uint versCreate)
        {
            if (tableInfo == null)
            {
                return(DBConstants.EMPTY_STRING);
            }

            string strFieldNames = "(";

            foreach (var field in tableInfo.TableColumnsForVersion(versCreate))
            {
                string strFieldName = field.m_strName;
                strFieldName += " ";
                strFieldName += DbConvertDataType(field);
                strFieldName += " ";
                strFieldName += DbIdentity(field);
                strFieldName += DbNullAndDefault(field);

                strFieldNames += NEW_LINE_STR;
                strFieldNames += strFieldName.Trim();
                strFieldNames += ",";
            }
            if (createRels && DbRelationInCreateTable())
            {
                strFieldNames = StringUtils.JoinNonEmpty(NEW_LINE_STR, strFieldNames, DbRelsDefinition(tableInfo));
            }
            if (DbXPIndexInCreateTable())
            {
                strFieldNames = StringUtils.JoinNonEmpty(NEW_LINE_STR, strFieldNames, DbPKsDefinition(tableInfo));
            }

            string retTableSql = strFieldNames.TrimEnd(DBConstants.TRIM_CHARS);

            retTableSql += ")";
            retTableSql += NEW_LINE_STR;
            return(retTableSql);
        }
Ejemplo n.º 4
0
        public override string CreateTableBND(TableDefInfo tableDef, uint versCreate)
        {
            string strSQL      = "";
            var    tableFields = tableDef.TableColumnsForVersion(versCreate);

            foreach (var field in tableFields)
            {
                string strDefaultSQL;
                bool   bRequiredDefault = DBPlatform.DefaultBindRequired(field.m_lAttributes);

                if (field.m_bRequired && bRequiredDefault)
                {
                    if (DBPlatform.DefaultBindDataType(field.m_nType))
                    {
                        strDefaultSQL = BindDefaultDataTypeSql(tableDef.TableName(), field.m_strName);
                        strSQL       += (strDefaultSQL);
                        strSQL       += DBConstants.NEW_LINE_STR;
                        strSQL       += DBConstants.NEW_LINE_STR;
                    }
                }
            }

            return(strSQL);
        }