Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
/ t4models Public archive

Commit

Permalink
Version 1.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ili authored Jul 6, 2017
2 parents 4b98337 + c9dec4a commit 444c497
Show file tree
Hide file tree
Showing 53 changed files with 396 additions and 254 deletions.
4 changes: 2 additions & 2 deletions NuGet/linq2db.Access.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.Access</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to Access</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -18,7 +18,7 @@
</summary>
<tags>linq linq2db Access LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.DB2.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.DB2</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to IBM DB2</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -19,7 +19,7 @@
</summary>
<tags>linq linq2db DB2 LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.Firebird.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.Firebird</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to Firebird</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -18,7 +18,7 @@
</summary>
<tags>linq linq2db Firebird LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.Informix.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.Informix</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to Informix</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -19,7 +19,7 @@
</summary>
<tags>linq linq2db Informix LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.MySql.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.MySql</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to MySql</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -18,7 +18,7 @@
</summary>
<tags>linq linq2db MySql LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.Oracle.Managed.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.Oracle.Managed</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to Oracle (ODP.NET) Managed</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -19,7 +19,7 @@
</summary>
<tags>linq linq2db Oracle LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.Oracle.x64.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.Oracle.x64</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to Oracle (ODP.NET) x64</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -19,7 +19,7 @@
</summary>
<tags>linq linq2db Oracle ODP LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.Oracle.x86.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.Oracle.x86</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to Oracle (ODP.NET) x86</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -19,7 +19,7 @@
</summary>
<tags>linq linq2db Oracle ODP LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.PostgreSQL.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.PostgreSQL</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to PostgreSQL</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -18,7 +18,7 @@
</summary>
<tags>linq linq2db Npgsql PostgreSQL LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.SQLite.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.SQLite</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to SQLite</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -18,7 +18,7 @@
</summary>
<tags>linq linq2db SQLite LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.SapHana.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.SapHana</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to SAP HANA</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -19,7 +19,7 @@
</summary>
<tags>linq linq2db SapHana LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.SqlCe.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.SqlCe</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to SqlCe</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -18,7 +18,7 @@
</summary>
<tags>linq linq2db SqlCe SqlServerCe SqlServer Compact LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.SqlServer.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.SqlServer</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to SqlServer</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -18,7 +18,7 @@
</summary>
<tags>linq linq2db SqlServer LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/linq2db.Sybase.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.Sybase</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to Sybase ASE</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -19,7 +19,7 @@
</summary>
<tags>linq linq2db Sybase LinqToDB ORM database DB SQL</tags>
<dependencies>
<dependency id="linq2db.t4models" version="1.8.2"/>
<dependency id="linq2db.t4models" version="1.8.3"/>
</dependencies>
</metadata>
<files>
Expand Down
8 changes: 4 additions & 4 deletions NuGet/linq2db.t4models.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>linq2db.t4models</id>
<version>1.8.2</version>
<version>1.8.3</version>
<title>LINQ to DB T4 Models</title>
<authors>Igor Tkachev</authors>
<owners />
Expand All @@ -23,17 +23,17 @@
<dependencies>

<group targetFramework="netstandard1.6">
<dependency id="linq2db.Core" version="1.8.2"/>
<dependency id="linq2db.Core" version="1.8.3"/>
</group>

<group targetFramework="net40">
<dependency id="linq2db" version="1.8.2"/>
<dependency id="linq2db" version="1.8.3"/>
</group>

</dependencies>
</metadata>
<files>
<file src="..\packages\linq2db.1.8.2\lib\net40\linq2db.dll" target="tools" />
<file src="..\packages\linq2db.1.8.3\lib\net40\linq2db.dll" target="tools" />
<file src="init.ps1" target="tools" />

<file src="..\ReadMe.md" target="content\LinqToDB.Templates" />
Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,32 @@ GetSchemaOptions.ExcludedCatalogs = new[] { "TestUser", "SYSSTAT" }; // Defines
GetSchemaOptions.IncludedCatalogs = new[] { "TestUser", "SYS" }; // Defines only included catalogs.
```

## Provider specific configurations
### SQL Server
```cs
bool GenerateSqlServerFreeText = true; // Defines wheather to generate extensions for Free Text search, or not
```
### PostgreSQL
```cs
bool GenerateCaseSensitiveNames = false; // Defines whether to generate case sensitive or insensitive names
```
### Sybase
```cs
bool GenerateSybaseSystemTables = false; // Defines whether to generate Sybase sysobjects tables or not
```

## Customizing generation process

Use the following code to modify your model **before** you call the `GenerateModel()` method.

```c#
GetTable("Person").TypeName = "MyName"; // Replaces table name.
GetColumn("Person", "PersonID").MemberName = "ID"; // Replaces column PersonID of Person table with ID.
GetTable("Person").TypeName = "MyName"; // Replaces table name.
GetTable("Person").BaseClass = "PersonBase, IId"; // Set base class & interface for type, null to reset
GetColumn("Person", "PersonID") .MemberName = "ID"; // Replaces column PersonID of Person table with ID.
GetColumn("Person", "PasswordHash").SkipOnUpdate = true; // Set [Column(SkipOnUpdate=true)], same for other column options
GetColumn("Person", "Gender") .Type = "global::Model.Gender"; // Change column type
GetFK("Orders", "FK_Orders_Customers").MemberName = "Customers"; // Replaces association name.
GetFK("Orders", "FK_Orders_Customers").AssociationType = AssociationType.OneToMany; // Changes association type.
Expand Down
31 changes: 27 additions & 4 deletions Templates/DataModel.ttinclude
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,41 @@ void LoadMetadata(DataConnection dataConnection)
if (col.MemberName == t.TypeName)
col.MemberName += "_Column";
}

var duplicates = t.Columns.Values.ToLookup(c => c.MemberName).Where(g => g.Count() > 1);
foreach (var d in duplicates)
{
var alreadyNamed = new HashSet<string>();
foreach (var col in d)
{
col.MemberName = col.ColumnName;
if (keyWords.Contains(col.MemberName))
col.MemberName = "@" + col.MemberName;

col.MemberName = ConvertToCompilable(col.MemberName, false);

if (col.MemberName == t.TypeName)
col.MemberName += "_Column";

while (alreadyNamed.Contains(col.MemberName))
{
col.MemberName += "_";
}
alreadyNamed.Add(col.MemberName);
}
}
}

AfterLoadMetadata();
}

string ConvertToCompilable(string name)
string ConvertToCompilable(string name, bool mayRemoveUnderscore = true)
{
var query =
from c in name
select char.IsLetterOrDigit(c) || c == '@' ? c : '_';

return ToValidName(new string(query.ToArray()));
return ToValidName(new string(query.ToArray()), mayRemoveUnderscore);
}

Table GetTable(string name)
Expand Down Expand Up @@ -638,9 +661,9 @@ public class Parameter
}

int _counter = 0;
string ToValidName(string name)
string ToValidName(string name, bool mayRemoveUnderscore = true)
{
if (NormalizeNames && name.Contains("_"))
if (NormalizeNames && mayRemoveUnderscore && name.Contains("_"))
{
name = SplitAndJoin(name, "", '_');
}
Expand Down
2 changes: 1 addition & 1 deletion Templates/LinqToDB.PostgreSQL.ttinclude
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
#><#+

bool GenerateCaseSensitiveNames = false;
bool GenerateCaseSensitiveNames = false; // Defines whether to generate case sensitive or insensitive names

void SetCaseSensitiveNames()
{
Expand Down
Loading

0 comments on commit 444c497

Please sign in to comment.