/// <summary> /// The method is called when the user has selected to view a single table. /// The method generates a select on all fields, with no joins. /// </summary> /// <param name="selectedTable">The designer metadata designating the table.</param> /// <returns>The string containing the SQL command.</returns> private StringBuilder GenerateFromTable(TablesAutomation.ITable selectedTable) { var result = new StringBuilder(); // It is indeed a table. Look at the properties if (!selectedTable.IsKernelTable) { bool first = true; result.AppendLine(string.Format(CultureInfo.InvariantCulture, "use {0}", BusinessDatabaseName)); result.AppendLine("go"); Stack <AxTable> tables = this.SuperTables(selectedTable.Name); // List any developer documentation as a SQL comment: if (!string.IsNullOrEmpty(selectedTable.DeveloperDocumentation)) { result.Append("-- " + selectedTable.Name); result.AppendLine(" : " + this.ResolveLabel(selectedTable.DeveloperDocumentation)); } else { result.AppendLine(); } result.AppendLine("select "); this.AddFields(result, tables.First(), tables.First().Fields, ref first); this.AddSystemFields(result, tables.First(), ref first); result.AppendLine("from " + SqlNameMangling.GetSqlTableName(tables.First().Name)); // If this table saves data per company, then add the where clause for // the user to fill out or ignore. if (tables.First().SaveDataPerCompany == Metadata.Core.MetaModel.NoYes.Yes) { result.AppendLine("-- where " + SqlNameMangling.GetValidSqlNameForField("DataAreaId") + " = 'DAT'"); } } return(result); }