First, thank you! I can live with it the way it is.
I do have another question about MyGeneration and specifically with the ES templates.
I need to create a single class from database schema with nested classes and I'm not sure how to setup the templates to keep looping and loop thru all the tables and save the whole thing as one file.
As you know, I am working on a Query Builder utility/ GUI and I discovered that its also useful within VS as well as the GUI.
I want to build classes similar to this:
Code:
public static class QueryDataConstants {
public static class Tables {
/// <summary>
/// The Employees table.
/// </summary>
public static class Employees {
public const string Name = "Employees";
public const string Alias = "e";
/// <summary>
/// The Employees table primary key fields.
/// </summary>
public static class PrimaryKeyFields {
public const string EmployeeID = "EmployeeID";
}
public static class Fields {
public static class EmployeeID {
public const string Name = "EmployeeID";
public const string DatabaseType = "int";
public const string SystemType = "System.Int32";
}
public static class FirstName {
public const string Name = "FirstName";
public const string DatabaseType = "nvarchar";
public const string SystemType = "System.String";
}
public static class LastName {
public const string Name = "LastName";
public const string DatabaseType = "nvarchar";
public const string SystemType = "System.String";
}
public static class Title {
public const string Name = "Title";
public const string DatabaseType = "nvarchar";
public const string SystemType = "System.String";
}
public static class TitleOfCourtesy {
public const string Name = "TitleOfCourtesy";
public const string DatabaseType = "nvarchar";
public const string SystemType = "System.String";
}
public static class BirthDate {
public const string Name = "BirthDate";
public const string DatabaseType = "datetime";
public const string SystemType = "System.DateTime";
}
public static class HireDate {
public const string Name = "HireDate";
public const string DatabaseType = "datetime";
public const string SystemType = "System.DateTime";
}
}
}
/// <summary>
/// The EmployeeTerritories table.
/// </summary>
public static class EmployeeTerritories {
public const string Name = "EmployeeTerritories";
public const string Alias = "et";
}
/// <summary>
/// The Territories table.
/// </summary>
public static class Territories {
public const string Name = "Territories";
public const string Alias = "t";
}
}
}
This allows for the easiest references to database schema I can think of using intellisense.
Here i a sample getting to the 'EmployeeID' of the 'Employees' table:
Code:
string employeeID = QueryDataConstants.Tables.Employees.Fields.EmployeeID;
Here is a screenshot of intellisense:
Anyways, I believe this section from an ES My Generation template needs to be modified (I copied the template into my own and modified all the rest just fine, I just need to save the whole thing as one file rather than one for each table):
Code:
// Save the output file for this Table/View
private void SaveFile()
{
string filename = input["txtPath"].ToString();
if (!filename.EndsWith("\\") )
filename += "\\";
filename += "I" + esPlugIn.Entity(source) + ".cs";
// This overwrites files with the same name
// without prompting. If you do not want to
// overwrite files with the same name, then
// use the following:
// output.save(filename, "d");
output.save(filename, false);
// This accumulates all output for all tables/views
// for display on the Output tab, above. Then, it clears
// the output, so each file saved only has the
// generated code for the one table/view.
outputBuffer += output.text;
output.clear();
context.Log.Write("Created " + filename);
}
If you could help me modify that to save all the tables in one file, I would be very appreciative.