/// <summary> /// Retrieves expressions into ICreateExpressionRoot /// </summary> /// <param name="expressionRoot">The root expression for a CREATE operation</param> /// <typeparam name="TEntity">Entity type</typeparam> public static void TableFor <TEntity>(this ICreateExpressionRoot expressionRoot) where TEntity : BaseEntity { var type = typeof(TEntity); var builder = expressionRoot.Table(NameCompatibilityManager.GetTableName(type)) as CreateTableExpressionBuilder; builder.RetrieveTableExpressions(type); }
/// <summary> /// Creates a table in Schema {<paramref name="migration"/>.SchemaName}<br/> /// If {migration.SchemaPrefix} have a value, the Syntax-TableName will be computed to {<paramref name="migration"/>.SchemaPrefix}{<paramref name="tableName"/>}<br/> /// If NOT, the Syntax-TableName will be the same as {<paramref name="tableName"/>} /// </summary> /// <param name="root">Expression root to extend</param> /// <param name="tableName"> /// The table name<br/> /// See summary-section how this parameter is used /// </param> /// <param name="migration"></param> /// <returns></returns> public static ICreateTableWithColumnOrSchemaOrDescriptionSyntax Table(this ICreateExpressionRoot root, string tableName, IMigrationModel migration) { var syntax = root.Table(migration.GetPrefixedName(tableName)); syntax.InSchema(migration.SchemaName); return(syntax); }
public static ICreateTableWithColumnSyntax TableForEntity <TEntity>(this ICreateExpressionRoot root) where TEntity : class, IEntity { var tableName = TableName.ForEntity <TEntity>(); return(root.Table(tableName)); }
/// <summary> /// Retrieves expressions into ICreateExpressionRoot /// </summary> /// <param name="expressionRoot">The root expression for a CREATE operation</param> /// <typeparam name="TEntity">Entity type</typeparam> public virtual void BuildTable <TEntity>(ICreateExpressionRoot expressionRoot) { var type = typeof(TEntity); var builder = expressionRoot.Table(NameCompatibilityManager.GetTableName(type)) as CreateTableExpressionBuilder; RetrieveTableExpressions(type, builder); }
public static ICreateTableColumnOptionOrWithColumnSyntax TableForModel(this ICreateExpressionRoot expressionRoot, string name) { return(expressionRoot.Table(name).WithColumn("Id").AsInt32().PrimaryKey().Identity()); }
public static ICreateIndexOnColumnSyntax Index(this ICreateExpressionRoot syntax, string schema, string table) { return(syntax.Index().OnTable(table).InSchema(schema)); }
public static ICreateColumnAsTypeSyntax Column(this ICreateExpressionRoot syntax, string schema, string table, string column) { return(syntax.Column(column).OnTable(table).InSchema(schema)); }
/// <summary> /// Создает таблицу с именем на основе типа <typeparamref name="TTable"/>. /// </summary> /// <returns>См. <see cref="ICreateExpressionRoot.Table(string)"/>.</returns> /// <remarks>В качестве имени таблицы используется значение атрибута <see cref="TableAttribute"/> или имя типа в единственном числе.</remarks> public static ICreateTableWithColumnOrSchemaOrDescriptionSyntax Table <TTable>(this ICreateExpressionRoot create) { return(create.Table(GetTableName <TTable>())); }
public static ICreateTableWithColumnOrSchemaOrDescriptionSyntax Table(this ICreateExpressionRoot create, Tables table) { var tableName = Enum.GetName(typeof(Tables), table); return(create.Table(tableName)); }
public static ICreateSchemaOptionsSyntax AppSchema(this ICreateExpressionRoot createExpressionRoot) { return(createExpressionRoot.Schema(Name)); }
public static ICreateTableWithColumnSyntax AppTable(this ICreateExpressionRoot createExpressionRoot, string tableName) { return(createExpressionRoot.Table(tableName).InSchema(SchemaExtensions.Name)); }
public static ICreateTableWithColumnSyntax DictionaryTable(this ICreateExpressionRoot createExpressionRoot, string tableName) { return(createExpressionRoot.Table(tableName) .WithColumn("Id").AsInt32().PrimaryKey().Identity().NotNullable() .WithColumn("Name").AsString(2000).Unique("IX_" + tableName + "_Name").NotNullable()); }
public static ICreateForeignKeyCascadeSyntax ForeignKey <TFromEntity, TToEntity>(this ICreateExpressionRoot root, string fromColumnName = null, string toColumnName = "Id") where TFromEntity : class, IEntity where TToEntity : class, IEntity { var tableFrom = TableName.ForEntity <TFromEntity>(); var tableTo = TableName.ForEntity <TToEntity>(); fromColumnName = fromColumnName ?? $"{tableTo}{ColumnName.PrimaryKey}"; toColumnName = toColumnName ?? ColumnName.PrimaryKey; return(root .ForeignKey($"FK_{tableFrom}_{fromColumnName}_{tableTo}_{toColumnName}") .FromTable(tableFrom) .ForeignColumn(fromColumnName) .ToTable(tableTo) .PrimaryColumn(toColumnName)); }
public static ICreateTableWithColumnOrSchemaSyntax Table <T>(this ICreateExpressionRoot root) { return(root.Table(typeof(T).Name)); }