Function Reference

The InMemoryDatabaseModelInclude.tt T4 include file provides the following functions to handle common taskes with the DacFx object model.

TSqlModel GetInMemoryDatabaseModel()
Builds an in-memory database model of what is in the current project. Always call within a using statement.

List<TSqlObject> GetAllTables(TSqlModel model)
Simply returns all tables in the database model.

List<TSqlObject> GetAllTablesInSchema(TSqlModel model, string schemaName)
Returns all tables in a specific schema.

List<TSqlObject> GetAllTablesInSchemaWithPrefixes(TSqlModel model, string schemaName, string[] prefixes)
Returns all tables in a specific schema which also have a prefix listed in the list of prefixes supplied.

List<TSqlObject> GetAllObjectsOfSpecifiedType(TSqlModel model, ModelTypeClass dbObjectType)
This is a generic function which simply returns all objects of the specified type in the model. A full list of ModelTypeClass can be found here ModelSchema Class and should be written in the form: ModelSchema.XXX (e.g. ModelSchema.Table)

List<TSqlObject> GetAllObjectsInSchema(TSqlModel model, ModelTypeClass dbObjectType, string schemaNameToMatch)
Same as GetAllObjectsOfSpecifiedType but more generic as it returns all objects of the specified type in a specific schema. A full list of ModelTypeClass can be found here ModelSchema Class and should be written in the form: ModelSchema.XXX (e.g. ModelSchema.Table).

List<TSqlObject> GetAllObjectsInSchemaWithPrefixes(TSqlModel model, ModelTypeClass dbObjectType, string schemaNameToMatch, string[] prefixes)
Same as GetAllObjectsOfSpecifiedType but more generic as it returns all objects of the specified type in a specific schema and starting with one of the prefixes passed in the list. A full list of ModelTypeClass can be found here ModelSchema Class and should be written in the form: ModelSchema.XXX (e.g. ModelSchema.Table).

List<TSqlObject> GetPrimaryKeyColumns(TSqlObject table)
Returns a list of columns which form the primary key collection for the table.

List<ModelRelationshipInstance> GetForeignKeyColumns(TSqlObject table)
Returns a list of ModelRelationshipInstance objects representing all the foreign key relationships for the table.

string GetColumnDefinition(TSqlObject column)
Returns the column definition in the format expected by SQL CREATE TABLE scripts

string GetColumnName(TSqlObject column)
Simply returns the name of the column.

Last edited Jul 8, 2015 at 12:23 PM by JohnTunnicliffe, version 3