OrmLiteSchemaApi
Assembly: ServiceStack.OrmLite.dll
View Source
public static class OrmLiteSchemaApi : object
Methods
TableExists(IDbConnection, String, String)
Checks whether a Table Exists. E.g: <p>db.TableExists("Person")</p>
View Source
public static bool TableExists(this IDbConnection dbConn, string tableName, string schema = null)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
System.String | tableName |
System.String | schema |
TableExistsAsync(IDbConnection, String, String, CancellationToken)
Checks whether a Table Exists. E.g: <p>db.TableExistsAsync("Person")</p>
View Source
public static Task<bool> TableExistsAsync(this IDbConnection dbConn, string tableName, string schema = null, CancellationToken token = null)
Returns
Task<System.Boolean>
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
System.String | tableName |
System.String | schema |
CancellationToken | token |
TableExists<T>(IDbConnection)
Checks whether a Table Exists. E.g: <p>db.TableExists<Person>()</p>
View Source
public static bool TableExists<T>(this IDbConnection dbConn)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type Parameters
T
TableExistsAsync<T>(IDbConnection, CancellationToken)
Checks whether a Table Exists. E.g: <p>db.TableExistsAsync<Person>()</p>
View Source
public static Task<bool> TableExistsAsync<T>(this IDbConnection dbConn, CancellationToken token = null)
Returns
Task<System.Boolean>
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
CancellationToken | token |
Type Parameters
T
ColumnExists(IDbConnection, String, String, String)
Checks whether a Table Column Exists. E.g: <p>db.ColumnExists("Age", "Person")</p>
View Source
public static bool ColumnExists(this IDbConnection dbConn, string columnName, string tableName, string schema = null)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
System.String | columnName |
System.String | tableName |
System.String | schema |
ColumnExistsAsync(IDbConnection, String, String, String, CancellationToken)
Checks whether a Table Column Exists. E.g: <p>db.ColumnExistsAsync("Age", "Person")</p>
View Source
public static Task<bool> ColumnExistsAsync(this IDbConnection dbConn, string columnName, string tableName, string schema = null, CancellationToken token = null)
Returns
Task<System.Boolean>
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
System.String | columnName |
System.String | tableName |
System.String | schema |
CancellationToken | token |
ColumnExists<T>(IDbConnection, Expression<Func<T, Object>>)
Checks whether a Table Column Exists. E.g: <p>db.ColumnExists<Person>(x => x.Age)</p>
View Source
public static bool ColumnExists<T>(this IDbConnection dbConn, Expression<Func<T, object>> field)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Expression<Func<<T>,System.Object>> | field |
Type Parameters
T
ColumnExistsAsync<T>(IDbConnection, Expression<Func<T, Object>>, CancellationToken)
Checks whether a Table Column Exists. E.g: <p>db.ColumnExistsAsync<Person>(x => x.Age)</p>
View Source
public static Task<bool> ColumnExistsAsync<T>(this IDbConnection dbConn, Expression<Func<T, object>> field, CancellationToken token = null)
Returns
Task<System.Boolean>
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Expression<Func<<T>,System.Object>> | field |
CancellationToken | token |
Type Parameters
T
CreateSchema<T>(IDbConnection)
Create a DB Schema from the Schema attribute on the generic type. E.g: <p>db.CreateSchema<Person>() //default</p>
View Source
public static void CreateSchema<T>(this IDbConnection dbConn)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type Parameters
T
CreateSchema(IDbConnection, String)
Create a DB Schema. E.g: <p>db.CreateSchema("schemaName")</p>
View Source
public static bool CreateSchema(this IDbConnection dbConn, string schemaName)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
System.String | schemaName |
CreateTables(IDbConnection, Boolean, Type[])
Create DB Tables from the schemas of runtime types. E.g: <p>db.CreateTables(typeof(Table1), typeof(Table2))</p>
View Source
public static void CreateTables(this IDbConnection dbConn, bool overwrite, params Type[] tableTypes)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
System.Boolean | overwrite |
Type[] | tableTypes |
CreateTable(IDbConnection, Boolean, Type)
Create DB Table from the schema of the runtime type. Use overwrite to drop existing Table. E.g: <p>db.CreateTable(true, typeof(Table))</p>
View Source
public static void CreateTable(this IDbConnection dbConn, bool overwrite, Type modelType)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
System.Boolean | overwrite |
Type | modelType |
CreateTableIfNotExists(IDbConnection, Type[])
Only Create new DB Tables from the schemas of runtime types if they don't already exist. E.g: <p>db.CreateTableIfNotExists(typeof(Table1), typeof(Table2))</p>
View Source
public static void CreateTableIfNotExists(this IDbConnection dbConn, params Type[] tableTypes)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type[] | tableTypes |
DropAndCreateTables(IDbConnection, Type[])
Drop existing DB Tables and re-create them from the schemas of runtime types. E.g: <p>db.DropAndCreateTables(typeof(Table1), typeof(Table2))</p>
View Source
public static void DropAndCreateTables(this IDbConnection dbConn, params Type[] tableTypes)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type[] | tableTypes |
CreateTable<T>(IDbConnection, Boolean)
Create a DB Table from the generic type. Use overwrite to drop the existing table or not. E.g: <p>db.CreateTable<Person>(overwrite=false) //default</p> <p>db.CreateTable<Person>(overwrite=true)</p>
View Source
public static void CreateTable<T>(this IDbConnection dbConn, bool overwrite = false)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
System.Boolean | overwrite |
Type Parameters
T
CreateTableIfNotExists<T>(IDbConnection)
Only create a DB Table from the generic type if it doesn't already exist. E.g: <p>db.CreateTableIfNotExists<Person>()</p>
View Source
public static bool CreateTableIfNotExists<T>(this IDbConnection dbConn)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type Parameters
T
CreateTableIfNotExists(IDbConnection, Type)
Only create a DB Table from the runtime type if it doesn't already exist. E.g: <p>db.CreateTableIfNotExists(typeof(Person))</p>
View Source
public static bool CreateTableIfNotExists(this IDbConnection dbConn, Type modelType)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type | modelType |
DropAndCreateTable<T>(IDbConnection)
Drop existing table if exists and re-create a DB Table from the generic type. E.g: <p>db.DropAndCreateTable<Person>()</p>
View Source
public static void DropAndCreateTable<T>(this IDbConnection dbConn)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type Parameters
T
DropAndCreateTable(IDbConnection, Type)
Drop existing table if exists and re-create a DB Table from the runtime type. E.g: <p>db.DropAndCreateTable(typeof(Person))</p>
View Source
public static void DropAndCreateTable(this IDbConnection dbConn, Type modelType)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type | modelType |
DropTables(IDbConnection, Type[])
Drop any existing tables from their runtime types. E.g: <p>db.DropTables(typeof(Table1),typeof(Table2))</p>
View Source
public static void DropTables(this IDbConnection dbConn, params Type[] tableTypes)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type[] | tableTypes |
DropTable(IDbConnection, Type)
Drop any existing tables from the runtime type. E.g: <p>db.DropTable(typeof(Person))</p>
View Source
public static void DropTable(this IDbConnection dbConn, Type modelType)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type | modelType |
DropTable<T>(IDbConnection)
Drop any existing tables from the generic type. E.g: <p>db.DropTable<Person>()</p>
View Source
public static void DropTable<T>(this IDbConnection dbConn)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type Parameters
T
GetSchemas(IDbConnection)
Get a list of available user schemas for this connection
View Source
public static List<string> GetSchemas(this IDbConnection dbConn)
Returns
List<System.String>
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
GetSchemaTables(IDbConnection)
Get available user Schemas and their tables for this connection
View Source
public static Dictionary<string, List<string>> GetSchemaTables(this IDbConnection dbConn)
Returns
Dictionary<System.String,List<System.String>>
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Migrate<T>(IDbConnection)
Alter tables by adding properties for missing columns and removing properties annotated with [RemoveColumn]
View Source
public static void Migrate<T>(this IDbConnection dbConn)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type Parameters
T
Revert<T>(IDbConnection)
Apply schema changes by Migrate in reverse to revert changes
View Source
public static void Revert<T>(this IDbConnection dbConn)
Parameters
Type | Name |
---|---|
IDbConnection | dbConn |
Type Parameters
T