This repository was archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathProgram.cs
More file actions
63 lines (52 loc) · 2.15 KB
/
Program.cs
File metadata and controls
63 lines (52 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.IO;
using POCOGenerator;
using POCOGenerator.Objects;
namespace WildcardsDemo
{
class Program
{
static void Main()
{
IGenerator generator = GeneratorFactory.GetGenerator();
try { generator.Settings.Connection.ConnectionString = File.ReadAllText("ConnectionString.txt"); } catch { }
if (string.IsNullOrEmpty(generator.Settings.Connection.ConnectionString))
generator.Settings.Connection.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=AdventureWorks2014;Integrated Security=True";
// all the tables under Sales schema
generator.Settings.DatabaseObjects.Tables.Include.Add("Sales.*");
// HumanResources.Employee but not HumanResources.EmployeeDepartmentHistory
// or HumanResources.EmployeePayHistory
generator.Settings.DatabaseObjects.Tables.Include.Add("Employe?");
generator.ServerBuilt += (object sender, ServerBuiltEventArgs e) =>
{
foreach (Database database in e.Server.Databases)
{
foreach (Table table in database.Tables)
Console.WriteLine(table);
}
// do not generate classes
e.Stop = true;
};
GeneratorResults results = generator.Generate();
PrintError(results, generator.Error);
Console.WriteLine();
Console.WriteLine("Press any key to continue . . .");
Console.ReadKey(true);
}
private static void PrintError(GeneratorResults results, Exception Error)
{
bool isError = (results & GeneratorResults.Error) == GeneratorResults.Error;
if (isError)
{
Console.WriteLine();
Console.WriteLine("Error Result: {0}", results);
}
if (Error != null)
{
Console.WriteLine("Error: {0}", Error.Message);
Console.WriteLine("Error Stack Trace:");
Console.WriteLine(Error.StackTrace);
}
}
}
}