Table of Contents [Hide/Show]
Supported databases Setup VB Support Customization WCF Support Pluralize / Singularize Table Names
<#@ template language="C#v3.5" #> <#@ output extension=".generated.cs" #> <#@ include file="BLToolkit.ttinclude" #> <#@ include file="Sybase.ttinclude" #> <# ConnectionString = "Data Source=DBHost;Port=5000;Database=BLToolkitData;Uid=sa"; DataProviderAssembly = @"......\Sybase.AdoNet2.AseClient.dll"; Namespace = "Templates"; DataContextName = "DataModel"; GenerateModel(); #>
<#@ assembly name="Sybase.AdoNet2.AseClient" #>
<#@ template language="C#v3.5" #> <#@ output extension=".generated.cs" #> <#@ include file="BLToolkit.ttinclude" #> <#@ include file="MSSQL.ttinclude" #> <# ConnectionString = "Server=.;Database=BLToolkitData;Integrated Security=SSPI"; Namespace = "Templates"; DataContextName = "DataModel"; GenerateModel(); #>
<#@ template language="C#v3.5" hostspecific="True" #> <#@ output extension=".generated.cs" #> <#@ include file="BLToolkit.ttinclude" #> <#@ include file="BLT4Toolkit.ttinclude" #> <#@ include file="MSSQL.ttinclude" #> <# ConnectionString = "Server=.;Database=BLToolkitData;Integrated Security=SSPI"; GenerateModel(); #>
<#@ template language="C#v3.5" #> <#@ output extension=".generated.vb" #> <#@ include file="BLToolkit.ttinclude" #> <#@ include file="MSSQL.ttinclude" #> <#@ include file="VB.ttinclude" #> <# ConnectionString = "Server=.;Database=BLToolkitData;Integrated Security=SSPI"; Namespace = "Templates"; DataContextName = "DataModel"; GenerateModel(); #>
string DatabaseName = null; string DataContextName = "DataContext"; string Namespace = "DataModel"; string BaseDataContextClass = "DbManager"; string BaseEntityClass = null; string OneToManyAssociationType = "IEnumerable<{0}>"; bool RenderField = false;
<#@ template language="C#v3.5" #> <#@ output extension=".generated.cs" #> <#@ include file="BLToolkit.ttinclude" #> <#@ include file="MSSQL.ttinclude" #> <# ConnectionString = "Server=.;Database=BLToolkitData;Integrated Security=SSPI"; Namespace = "Templates"; DataContextName = "DataModel"; // This method has to be called before any metadata change. // LoadMetadata(); // Change the BinaryDataID field name of the BinaryData table to "ID". // Tables["BinaryData"].Columns["BinaryDataID"].MemberName = "ID"; // Change the FK_Employees_Employees association name of the Employees table to "ReportsToEmployee". // Tables["Employees"].ForeignKeys["FK_Employees_Employees"].MemberName = "ReportsToEmployee"; // Change a field name to "ID" if the field is a primary key and its name is ClassNameID. // foreach (var t in Tables.Values) foreach (var c in t.Columns.Values) if (c.IsPrimaryKey && t.TableName + "ID" == c.ColumnName) c.MemberName = "ID"; // Add inheritance to entity classes from EntityBase<T>. // Usings.Add("BLToolkit.Common"); foreach (var t in Tables.Values) t.BaseClassName = "EntityBase<" + t.ClassName + ">"; GenerateModel(); #>
Dictionary<string,Table> Tables = new Dictionary<string,Table>();partial class Table { public string Owner; public string TableName; public string ClassName; public string BaseClassName; public string DataContextPropertyName; public bool IsView; public List<string> Attributes; public Dictionary<string,Column> Columns; public Dictionary<string,ForeignKey> ForeignKeys; }partial class Column { public int ID; public string ColumnName; public string MemberName; public bool IsNullable; public bool IsIdentity; public string Type; public bool IsClass; public DbType DbType; public SqlDbType SqlDbType; public int PKIndex = -1; public List<string> Attributes = new List<string>(); public bool IsPrimaryKey; }enum AssociationType { Auto, OneToOne, OneToMany, ManyToOne, }partial class ForeignKey { public string KeyName; public string MemberName; public Table OtherTable; public List<Column> ThisColumns; public List<Column> OtherColumns; public bool CanBeNull; public ForeignKey BackReference; public AssociationType AssociationType; }
<#@ template language="C#v3.5" #> <#@ output extension=".generated.cs" #> <#@ include file="BLToolkit.ttinclude" #> <#@ include file="WCFAttributes.ttinclude" #> <#@ include file="MSSQL.ttinclude" #> <# ConnectionString = "Server=.;Database=BLToolkitData;Integrated Security=SSPI"; GenerateModel(); #>
<#@ template language="C#v3.5" #> <#@ output extension=".generated.cs" #> <#@ include file="BLToolkit.ttinclude" #> <#@ include file="MSSQL.ttinclude" #> <#@ include file="PluralSingular.ttinclude" #> <# ConnectionString = "Server=.;Database=BLToolkitData;Integrated Security=SSPI"; //PluralizeClassNames = true; SingularizeClassNames = true; PluralizeDataContextPropertyNames = true; //SingularizeDataContextPropertyNames = true; GenerateModel(); #>