Пример #1
0
        public static ColumnEditKeySchema GetTableForeignSchema(string SchemaName, string tableName)
        {
            MySqlParameter[] prams = new MySqlParameter[]
            {
                new MySqlParameter("?tableName", tableName)
            };
            DataTable           dataTable = SqlSchemaHelper.CodeSqlHelper.ExecuteDataTable(Resources.GetTableForeign, CommandType.Text, prams, "");
            ColumnEditKeySchema result;

            if (dataTable.Rows.Count > 0)
            {
                foreach (DataRow dataRow in SqlSchemaHelper.GetTableColumns(SchemaName, tableName, "").Rows)
                {
                    if (dataRow["FieldName"].ToString() == dataTable.Rows[0]["ForeignColumnName"].ToString() && dataTable.Rows[0]["PrimaryTableName"].ToString() != tableName)
                    {
                        result = new ColumnEditKeySchema
                        {
                            FieldName = dataRow["FieldName"].ToString(),
                            DateType  = dataRow["DataType"].ToString()
                        };
                        return(result);
                    }
                }
                result = null;
            }
            else
            {
                result = null;
            }
            return(result);
        }
Пример #2
0
        public static ColumnEditKeySchema GetTablePrimarySchema(string SchemaName, string tableName)
        {
            ColumnEditKeySchema result;

            foreach (DataRow dataRow in SqlSchemaHelper.GetTableColumns(SchemaName, tableName, "").Rows)
            {
                if (dataRow["FieldName"].ToString() == dataRow["TableKey"].ToString())
                {
                    result = new ColumnEditKeySchema
                    {
                        FieldName = dataRow["FieldName"].ToString(),
                        DateType  = dataRow["DataType"].ToString()
                    };
                    return(result);
                }
            }
            result = null;
            return(result);
        }