<#@ template language="C#" debug="True" hostSpecific="True" #>
<#@ output extension=".generated.cs"                        #>

<#@ include file="$(LinqToDBT4InformixTemplatesPath)LinqToDB.Informix.Tools.ttinclude" once="true" #>
<#@ include file="$(LinqToDBT4InformixTemplatesPath)PluralizationService.ttinclude"    once="true" #>
<#
/*
	1. Download and install IBM Data Server Provider for .NET.

	2. Add a reference to IBM.Data.Informix.dll.

	3. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model
		and copy content from this file to it. For example:

		MyProject
			DataModels
				MyDatabase.tt

	4. Modify the connection settings below to connect to your database.

	5. Add connection string to the web/app.config file:

		<connectionStrings>
			<add name="MyDatabase"
				connectionString="Server=MyServer:9088;Database=MyDatabase;userid=informix;password=TestPassword;"
				providerName="IBM.Data.DB2"/>
		</connectionStrings>

	6. To access your database use the following code:

		using (var db = new MyDatabaseDB())
		{
			var q =
				from c in db.Customers
				select c;

			foreach (var c in q)
				Console.WriteLine(c.ContactName);
		}

	7. See more at https://linq2db.github.io/articles/T4.html
*/

	// File settings
//	EnforceModelNullability             = true;                   // #nullable enable
//	EnableNullableReferenceTypes        = true;                   // #nullable enable

	// DataContext settings
	NamespaceName                       = "DataModels";           // DataContext class namespace name
//	DataContextName                     = "TestDataDB";           // DataContext class name
//	BaseDataContextClass                = "MyDataContext";        // name of the base DataContext class
//	GenerateDatabaseInfo                = true;                   // adds comment contained database info
//	GenerateFindExtensions              = true;                   // generate Find(...) extension methods
//	GenerateViews                       = true;                   // generate views

	// Schema settings
//	GenerateSchemaAsType                = false;                  // generate database schema as type (db.MySchema.MyTable)
//	SchemaNameSuffix                    = "Schema";               // schema type name suffix
//	SchemaDataContextTypeName           = "DataContext";          // schema DataContext type name
//	PrefixTableMappingWithSchema        = true;                   // add schema name as prefix to table type name
//	PrefixTableMappingForDefaultSchema  = false;                  // add default schema name as prefix to table type name

	// Constructors
//	GenerateConstructors                = true;                   // generate constructors
//	DefaultConfiguration                = "SqlServer";            // use default configuration
//	GetDataOptionsMethod                = "GetDataOptions({0})";  // constructors call user defined methods that returns DataOptions
//	GenerateDataOptionsConstructors     = true;                   // generate data options constructors

	// Entity class settings
//	BaseEntityClass                     = "MyEntity";             // entity base class
//	ServerName                          = "ServerName";           // specified server name
//	DatabaseName                        = "DatabaseName";         // specified database name
//	OneToManyAssociationType            = "IEnumerable<{0}>";     // association base type
//	GenerateDatabaseName                = ;                       // generate database name
//	GenerateDatabaseNameFromTable       = ;                       // generate database name from TableSchema.CatalogName
//	GenerateAssociations                = true;                   // generate associations
//	GenerateBackReferences              = true;                   // generate back references
//	GenerateAssociationExtensions       = false;                  // generate associations as extension methods
//	IncludeDefaultSchema                = true;                   // generated default schema name, such as 'dbo'

	// Column settings
//	GenerateObsoleteAttributeForAliases = false;                  // add ObsoleteAttribute to alias members
//	GenerateDataTypes                   = false;                  // generate column DataType
//	GenerateLengthProperty              = null;                   // generate column length
//	GeneratePrecisionProperty           = null;                   // generate column precision
//	GenerateScaleProperty               = null;                   // generate column scale
//	GenerateDbTypes                     = false;                  // generate column DbType
//	IsCompactColumns                    = true;                   // compact mode of column generation
//	IsCompactColumnAliases              = true;                   // compact mode of alias column generation

	// Identifier normalization
//	PluralizeClassNames                 = ;                       // pluralize class names
//	SingularizeClassNames               = true;                   // singularize class names
//	PluralizeDataContextPropertyNames   = true;                   // pluralize DataContext property names
//	SingularizeDataContextPropertyNames = ;                       // singularize DataContext property names
//	PluralizeForeignKeyNames            = true;                   // pluralize foreign key names
//	SingularizeForeignKeyNames          = true;                   // singularize foreign key names
//	NormalizeNames                      = true;                   // normalize names containing '_', lower case first letters, etc
//	NormalizeNamesWithoutUnderscores    = ;                       // normalize names without underscores

	// Stored procedures
//	ReplaceSimilarTables                = true;                   // when generate stored procedure results, use the same type if types are similar
//	GenerateProcedureErrors             = true;                   // generate stored procedure metadata errors
//	GenerateProcedureResultAsList       = false;                  // generate stored procedure result as List<T>
//	GenerateProceduresOnTypedContext    = true;                   // generate stored procedures on typed context

	// to configure GetSchemaOptions properties, add them here, before load metadata call

	LoadInformixMetadata("MyServer", "9088", "ol_informix1170", "MyDatabase", "informix", "TestPassword");
//	LoadInformixMetadata(string connectionString);

	// to adjust loaded database model before generation, add your code here, after load metadata, but before GenerateModel() call

//	GetTable("Order").TypeName                = "TheOrder";
//	GetTable("Order").DataContextPropertyName = "TheOrders";
//
//	GetColumn("Order", "OrderID").MemberName  = "ID";
//	GetColumn("Order", "Day").    Type        = "DayOfWeek";
//
//	foreach (var t in Tables.Values)
//	{
//		var pk = t.Columns.Values.FirstOrDefault(c => c.ColumnName == t.TableName + "ID" && c.Type == "int");
//
//		if (pk != null)
//		{
//			pk.MemberName = "ID";
//			t.Interfaces.Add("IIdentifiable");
//		}
//	}

	GenerateModel();
#>
