Skip to content
Snippets Groups Projects

Topic/122 nuget

Merged L. Ellenbeck requested to merge Topic/122-nuget into Product/109-nuget
31 files
+ 353
905
Compare changes
  • Side-by-side
  • Inline

Files

#region DupFinder Exclusion
<#@ template language="C#" debug="True" hostSpecific="False" #>
<#@ output extension=".generated.cs" #>
<# //@ include file="$(LinqToDBT4SqlServerTemplatesDirectory)LinqToDB.SqlServer.Tools.ttinclude" #>
<# //@ include file="$(LinqToDBT4SqlServerTemplatesDirectory)PluralizationService.ttinclude" #>
<#@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.Tools.ttinclude" #>
<#@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #>
<#@ include file="$(ProjectDir)DatabaseConnection.t4" #>
<#
/*
1. 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
2. Modify the connection settings below to connect to your database.
3. Add connection string to the web/app.config file:
<connectionStrings>
<add name="MyDatabase" providerName="System.Data.SqlClient"
connectionString="Data Source=.;Database=MyDatabase;User Id=User;Password=TestPassword;" />
</connectionStrings>
4. 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);
}
5. See more at https://github.com/linq2db/t4models
If you need to use the Microsoft.SqlServer.Types namespace, install the Microsoft.SqlServer.Types nuget,
and replace the following include at the top of this file:
"$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.Tools.ttinclude"
with
"$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.SqlTypes.Tools.ttinclude"
*/
NamespaceName = "Coscine.Database.Model";
#>
<#@ include file="$(ProjectDir)DatabaseConnection.ttinclude" #>
<# NamespaceName = "Coscine.Database.Model"; #>
<#
DatabaseConnection dbKeys = new DatabaseConnection();
string[] keys = dbKeys.GetConnectionKeys();
LoadSqlServerMetadata(keys[0], keys[1], keys[2], keys[3]);
// LoadSqlServerMetadata(".", "MyDatabase"); // Integrated Security
// LoadSqlServerMetadata(string connectionString);
GenerateModel();
#>
<#@ include file="$(ProjectDir)DataModelConstructor.ttinclude" #>
\ No newline at end of file
<#@ include file="../DataModelConstructor.t4"#>
#endregion
\ No newline at end of file
Loading