DbTable
static class · namespace z3n7 · source Db/DbExtencions.cs
public static class DbTable
Creating and inspecting tables of the project database.
Methods
EnsureTable
public static void EnsureTable(this IZennoPosterProjectModel project, TableSchema schema)
Extension method for IZennoPosterProjectModel. source
Creates the table described by schema if it does not exist.
| Parameter | Description |
|---|---|
schema |
Table name and columns, e.g. DbSchema.Process. |
PrepareProjectTable
public static void PrepareProjectTable(this IZennoPosterProjectModel project, string[] projectColumns, string tblName = null, bool log = false, bool prune = false, bool rearrange = false)
Extension method for IZennoPosterProjectModel. source
Array form of PrepareProjectTable(List<string>, …).
public static void PrepareProjectTable(this IZennoPosterProjectModel project, List<string> projectColumns = null, string tblName = null, bool log = false, bool prune = false, bool rearrange = false)
Extension method for IZennoPosterProjectModel. source
Creates the table with the TblForProject layout if needed and adds missing columns.
| Parameter | Description |
|---|---|
projectColumns |
Extra columns. |
tblName |
Table; default is the projectTable variable. |
log |
Write the query and its result to the project log. |
prune |
Also drop columns that are not in the layout. |
rearrange |
Also reorder columns to match the layout. |
public static void PrepareProjectTable(this IZennoPosterProjectModel project, Dictionary<string, string> tableStructure, string tblName = null, bool log = false, bool prune = false, bool rearrange = false)
Extension method for IZennoPosterProjectModel. source
Creates the table if needed and adds missing columns.
| Parameter | Description |
|---|---|
tableStructure |
Column → SQL type. |
tblName |
Table; default is the projectTable variable. |
log |
Write the query and its result to the project log. |
prune |
Also drop columns that are not in tableStructure. |
rearrange |
Also reorder columns to match tableStructure. |
TblAdd
public static void TblAdd(this IZennoPosterProjectModel project, Dictionary<string, string> tableStructure, string tblName, bool log = false)
Extension method for IZennoPosterProjectModel. source
Creates a table unless it exists. On PostgreSQL INTEGER PRIMARY KEY AUTOINCREMENT becomes SERIAL PRIMARY KEY.
| Parameter | Description |
|---|---|
tableStructure |
Column → SQL type. |
tblName |
Table; may be schema.table. |
log |
Write the query and its result to the project log. |
TblColumns
public static List<string> TblColumns(this IZennoPosterProjectModel project, string tblName, bool log = false)
Extension method for IZennoPosterProjectModel. source
Column names of a table.
| Parameter | Description |
|---|---|
tblName |
Table; on PostgreSQL may be schema.table. |
log |
Write the query and its result to the project log. |
TblExist
public static bool TblExist(this IZennoPosterProjectModel project, string tblName, bool log = false)
Extension method for IZennoPosterProjectModel. source
Checks whether a table exists.
| Parameter | Description |
|---|---|
tblName |
Table; on PostgreSQL may be schema.table (default schema public). |
log |
Write the query and its result to the project log. |
TblForProject
public static Dictionary<string, string> TblForProject(this IZennoPosterProjectModel project, List<string> projectColumns = null, string defaultType = "TEXT DEFAULT ''")
Extension method for IZennoPosterProjectModel. source
Builds a table layout: id INTEGER PRIMARY KEY AUTOINCREMENT, the given columns, and one column per item of the comma-separated cfgToDo variable.
| Parameter | Description |
|---|---|
projectColumns |
Extra columns. |
defaultType |
SQL type of every column except id. |
TblList
public static List<string> TblList(this IZennoPosterProjectModel project, bool log = false, string schema = "public")
Extension method for IZennoPosterProjectModel. source
Names of all tables, sorted.
| Parameter | Description |
|---|---|
log |
Write the query and its result to the project log. |
schema |
PostgreSQL schema. |
TblPrepareDefault
public static void TblPrepareDefault(this IZennoPosterProjectModel project, bool log = false)
Extension method for IZennoPosterProjectModel. source
Creates the project table (projectTable variable) with the TblForProject layout and adds missing columns.
| Parameter | Description |
|---|---|
log |
Write the query and its result to the project log. |