-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_partitions.cs
More file actions
28 lines (23 loc) · 864 Bytes
/
extract_partitions.cs
File metadata and controls
28 lines (23 loc) · 864 Bytes
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
//needed to write output on the filesystem
using System.IO;
string baseFilePath = @"C:\temp\TEscript\output\" + Model.Database.ToString() + @"\"; //where to store the output
string mFile;
string mScript;
//wreate the output directory if it doesn't exist
if (!Directory.Exists(baseFilePath))
{
Directory.CreateDirectory(baseFilePath);
}
var tables = Model.Tables; //loads all tables from the model
//tables.Output(); //uncomment to see the content of tables
foreach(var t in tables)
{
//for each table extract the query of the first partition
mScript = t.Partitions[0].Query;
//save query into a file
mFile = baseFilePath + t.Name.Replace("/", "") + ".m"; //optional step done to remove not allowed characters from filename
using (StreamWriter outputFile = new StreamWriter(mFile))
{
outputFile.WriteLine(mScript);
}
}