/// <summary> /// 创建数据表语句片段。 /// </summary> /// <param name="context">生成上下文。</param> /// <returns>语句片段。</returns> protected virtual SqlFragment GenerateForMaintenanceCreateTable(GenerateContext context) { var operate = (DbCreateTableOperate)context.Data.Operate; var metadata = context.Metadata.Table(context.Data.Operate.ClrType); if (operate.Type == EOperateType.CreateTable) { var name = context.ConvertName(operate.Name); return(new CreateTableFragment(context, metadata, name)); } else { var members = metadata.InheritSets.SelectMany(a => a.Members).Concat(metadata.Members); INameFragment name = null; if (operate.Type == EOperateType.CreateTempTable) { name = new TempTableNameFragment(context, operate.Name.Name); return(new CreateTempTableFragment(context, members, name) { IsVariable = false }); } else { name = new VariableFragment(context, operate.Name.Name); return(new CreateTempTableFragment(context, members, name) { IsVariable = true }); } } }
/// <summary> /// 创建重命名语句片段。 /// </summary> /// <param name="context">生成上下文。</param> /// <param name="name">对象名称。</param> /// <param name="kind">对象种类。</param> /// <param name="newName">新名称。</param> public RenameObjectFragment(GenerateContext context, INameFragment name, EDatabaseObject kind, string newName) : base(context) { Name = name; Kind = kind; NewName = newName; }
/// <summary> /// 初始化创建普通表。 /// </summary> /// <param name="context">生成上下文。</param> /// <param name="table">表元数据。</param> /// <param name="name">自定义表名称。</param> public CreateTableFragment(GenerateContext context, TableMetadata table, INameFragment name = null) : base(context) { Metadata = table; Name = name; if (name == null) { Name = new ObjectNameFragment(context, table.Name, table.Schema); } foreach (var col in table.Members) { Members.Add(new CreateColumnFragment(context, col, this)); } }
/// <summary> /// Returns the names of the enchantments. /// </summary> public virtual (INameFragment enhancement, INameFragment[] others) GetNames() { if (!this.Enchantments.Any()) { return(null, new INameFragment[0]); } INameFragment enhancementName = this.Enchantments.First(e => e is EnhancementBonus) .Name; INameFragment[] otherNames = this.Enchantments.Where(e => !(e is EnhancementBonus)) .Select(e => e.Name) .OrderBy(name => name.Text) .ToArray(); return(enhancementName, otherNames); }
/// <summary> /// 创建删除对象语句片段。 /// </summary> /// <param name="context">生成上下文。</param> /// <param name="name">对象名称。</param> /// <param name="kind">对象种类。</param> public DropObjectFragment(GenerateContext context, INameFragment name, EDatabaseObject kind) : base(context) { Name = name; Kind = kind; }
/// <summary> /// 初始化创建临时表。 /// </summary> /// <param name="context">生成上下文。</param> /// <param name="columns">指定的数据列。</param> /// <param name="name">自定义表名。</param> public CreateTempTableFragment(GenerateContext context, IEnumerable <ColumnMetadata> columns, INameFragment name = null) : this(context, new TemporaryTableFragment(context, columns, name)) { foreach (var col in columns) { Table.CreateMember(null, col); Members.Add(new CreateColumnFragment(context, col, this)); } }
/// <summary> /// 初始化创建关系。 /// </summary> /// <param name="context">生成上下文。</param> /// <param name="name">关系名称。</param> /// <param name="content">视图内容。</param> public CreateViewFragment(GenerateContext context, INameFragment name, string content) : base(context) { Name = name; Content = content; }
/// <summary> /// 初始化创建关系。 /// </summary> /// <param name="context">生成上下文。</param> /// <param name="name">关系名称。</param> public DropRelationFragment(GenerateContext context, INameFragment name) : base(context) { Name = name; }
/// <summary> /// Initializes a new instance of the <see cref="T:Core.Domain.Characters.Feats.Feat"/> class. /// </summary> /// <param name="name">The name of the feat.</param> /// <param name="webAddress">The URL of the feat. Must be http or https.</param> /// <exception cref="System.ArgumentException">Thrown when webAddress is not a well-formed http or https url.</exception> /// <exception cref="System.ArgumentNullException">Thrown when an argument is null.</exception> protected Feat(string name, string webAddress) { _name = new NameFragment(name, webAddress); }