internal static void Generate(DBConnection cn, TextWriter writer, string baseNamespace, Database database) { writer.WriteLine("namespace " + baseNamespace + "." + database.SecondaryDatabaseName + "TableConstants {"); foreach (var table in DatabaseOps.GetDatabaseTables(database)) { CodeGenerationStatics.AddSummaryDocComment(writer, "This object represents the constants of the " + table + " table."); writer.WriteLine("public class " + EwlStatics.GetCSharpSafeClassName(table.TableNameToPascal(cn)) + "Table {"); CodeGenerationStatics.AddSummaryDocComment(writer, "The name of this table."); writer.WriteLine("public const string Name = \"" + table + "\";"); foreach (var column in new TableColumns(cn, table, false).AllColumnsExceptRowVersion) { CodeGenerationStatics.AddSummaryDocComment(writer, "Contains schema information about this column."); writer.WriteLine("public class " + EwlStatics.GetCSharpSafeClassName(column.PascalCasedNameExceptForOracle) + "Column {"); CodeGenerationStatics.AddSummaryDocComment(writer, "The name of this column."); writer.WriteLine("public const string Name = \"" + column.Name + "\";"); CodeGenerationStatics.AddSummaryDocComment( writer, "The size of this column. For varchars, this is the length of the biggest string that can be stored in this column."); writer.WriteLine("public const int Size = " + column.Size + ";"); writer.WriteLine("}"); } writer.WriteLine("}"); } writer.WriteLine("}"); }
private static void writeInequalityConditionClasses(DBConnection cn, TextWriter writer, string table) { // NOTE: This kind of sucks. It seems like we could use generics to not have to write N of these methods into ISU.cs. writer.WriteLine("public static class " + EwlStatics.GetCSharpSafeClassName(table.TableNameToPascal(cn)) + "TableInequalityConditions {"); foreach (var column in new TableColumns(cn, table, false).AllColumnsExceptRowVersion) { CodeGenerationStatics.AddSummaryDocComment(writer, "A condition that narrows the scope of a command."); writer.WriteLine("public class " + GetConditionClassName(column) + ": " + GetTableConditionInterfaceName(cn, table) + " {"); writer.WriteLine("private readonly InequalityCondition.Operator op; "); writer.WriteLine("private readonly " + column.DataTypeName + " value;"); CodeGenerationStatics.AddSummaryDocComment( writer, "Creates a condition to narrow the scope of a command. Expression will read 'valueInDatabase op yourValue'. So new InequalityCondition( Operator.GreaterThan, value ) will turn into 'columnName > @value'."); writer.WriteLine("public " + GetConditionClassName(column) + "( InequalityCondition.Operator op, " + column.DataTypeName + " value ) {"); writer.WriteLine("this.op = op;"); writer.WriteLine("this.value = value;"); writer.WriteLine("}"); var colVal = column.GetCommandColumnValueExpression("value"); writer.WriteLine("InlineDbCommandCondition TableCondition.CommandCondition { get { return new InequalityCondition( op, " + colVal + " ); } }"); writer.WriteLine("}"); } writer.WriteLine("}"); // class }
internal static string GetClassName(DBConnection cn, string table, bool isRevisionHistoryTable, bool isRevisionHistoryClass) { return (EwlStatics.GetCSharpSafeClassName( isRevisionHistoryTable && !isRevisionHistoryClass ? "Direct" + table.TableNameToPascal(cn) + "ModificationWithRevisionBypass" : table.TableNameToPascal(cn) + "Modification")); }
private static void writeInConditionClasses(DBConnection cn, TextWriter writer, string table) { writer.WriteLine("public static class " + EwlStatics.GetCSharpSafeClassName(table.TableNameToPascal(cn)) + "TableInConditions {"); foreach (var column in new TableColumns(cn, table, false).AllColumnsExceptRowVersion) { CodeGenerationStatics.AddSummaryDocComment(writer, "A condition that narrows the scope of a command."); writer.WriteLine("public class " + GetConditionClassName(column) + ": " + GetTableConditionInterfaceName(cn, table) + " {"); writer.WriteLine("private readonly string subQuery;"); CodeGenerationStatics.AddSummaryDocComment(writer, "Creates a condition to narrow the scope of a command."); writer.WriteLine("public " + GetConditionClassName(column) + "( string subQuery ) {"); writer.WriteLine("this.subQuery = subQuery;"); writer.WriteLine("}"); writer.WriteLine("InlineDbCommandCondition TableCondition.CommandCondition { get { return new InCondition( \"" + column.Name + "\", subQuery ); } }"); writer.WriteLine("}"); } writer.WriteLine("}"); }
internal static string GetClassName(DBConnection cn, string table) { return(EwlStatics.GetCSharpSafeClassName(table.TableNameToPascal(cn) + "TableRetrieval")); }
internal static string GetTableEqualityConditionsClassName(DBConnection cn, string table) { return(EwlStatics.GetCSharpSafeClassName(table.TableNameToPascal(cn) + "TableEqualityConditions")); }
internal static string GetConditionClassName(Column column) { return(EwlStatics.GetCSharpSafeClassName(column.PascalCasedNameExceptForOracle == "Value" ? "_Value" : column.PascalCasedNameExceptForOracle)); }