jbubriski / ST4bby

A POCO generator that doesn't rely on the Entity Framework.
MIT License
17 stars 8 forks source link

Make the poco file name configurable #18

Closed LosManos closed 12 years ago

LosManos commented 12 years ago

Since ST4bby has the possibility to make the POCO classes configurable, shouldn't the file name be configurable too? Especially if the user puts ST4bby in the same folder as the custom partial custom class.

I have a local solution where the files are called Customer.ST4bby.cs etc. It also makes it easy to select the right files when deleting them before a new ST4bby.tt run.

codeimpossible commented 12 years ago

I like this idea, but what if we allowed the user to customize their file name using a pattern? Example:

File_name_format = "{schema}.{table}.St4bby.cs";

We could come up with a few different data points to use. What do you think?

LosManos commented 12 years ago

In an experimental branch I have this setting:

    // The format for the class file name.
    // Leave blank if the class name should be the same as the table's.
    // Use {0] for inserting the table's name. string.Format is used by ST4bby.
    // E.g. for a table called Customer:
    // "" => "Customer"
    // ".cs" => "Customer.cs"
    // "Record.ST4bby.cs" => "CustomerRecord.ST4bby.cs"
    // "The{0}Class" => "TheCustomerClass.cs"
    const string TableNameFormat = ".cs";

Do you follow how it works? Can it be extrapolated to both Schema and Table?

codeimpossible commented 12 years ago

so imagine if we could let the user do something like this:

// The format for the class file name.
// By default ST4bby uses the following format: {schema}.{tablename}
// You can use the following data points:
//   {schema} -> the schema of your table e.g. "dbo"
//   {table} -> the name of your table
//   {database} -> the name of your database
// ".cs" will be used as the file extension if it is not present at the end of the format
const string TableNameFormat = "{database}.{schema}.{table}";

Leaving the field blank should assume the default format, but the ST4bby should have this default filled out when it ships. Our code can then just be a series of String.Replace calls.

LosManos commented 12 years ago

File_name_format = "{schema}.{table}.St4bby.cs"; sounds like a good solution.