Skip to content
Snippets Groups Projects

Product/109 nuget

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

Files

 
#region DupFinder Exclusion
<#@ template language="C#" debug="True" hostSpecific="False" #>
<#@ template language="C#" debug="True" hostSpecific="False" #>
<#@ output extension=".generated.cs" #>
<#@ 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\LinqToDB.SqlServer.Tools.ttinclude" #>
<#@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #>
<#@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #>
 
<#@ include file="$(ProjectDir)DatabaseConnection.t4" #>
<#
<# NamespaceName = "Coscine.Database.Model"; #>
/*
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" #>
<#
<#
DatabaseConnection dbKeys = new DatabaseConnection();
DatabaseConnection dbKeys = new DatabaseConnection();
string[] keys = dbKeys.GetConnectionKeys();
string[] keys = dbKeys.GetConnectionKeys();
LoadSqlServerMetadata(keys[0], keys[1], keys[2], keys[3]);
LoadSqlServerMetadata(keys[0], keys[1], keys[2], keys[3]);
// LoadSqlServerMetadata(".", "MyDatabase"); // Integrated Security
// LoadSqlServerMetadata(string connectionString);
GenerateModel();
GenerateModel();
#>
#>
<#@ include file="$(ProjectDir)DataModelConstructor.ttinclude" #>
<#@ include file="../DataModelConstructor.t4"#>
\ No newline at end of file
 
#endregion
 
\ No newline at end of file
Loading