/// <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);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        public static ICreateTableWithColumnSyntax TableForEntity <TEntity>(this ICreateExpressionRoot root)
            where TEntity : class, IEntity
        {
            var tableName = TableName.ForEntity <TEntity>();

            return(root.Table(tableName));
        }
Пример #4
0
        /// <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);
        }
Пример #5
0
 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));
 }
Пример #8
0
 /// <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>()));
 }
Пример #9
0
        public static ICreateTableWithColumnOrSchemaOrDescriptionSyntax Table(this ICreateExpressionRoot create, Tables table)
        {
            var tableName = Enum.GetName(typeof(Tables), table);

            return(create.Table(tableName));
        }
Пример #10
0
 public static ICreateSchemaOptionsSyntax AppSchema(this ICreateExpressionRoot createExpressionRoot)
 {
     return(createExpressionRoot.Schema(Name));
 }
Пример #11
0
 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());
 }
Пример #13
0
        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));
        }
Пример #14
0
 public static ICreateTableWithColumnOrSchemaSyntax Table <T>(this ICreateExpressionRoot root)
 {
     return(root.Table(typeof(T).Name));
 }