Пример #1
0
		public static void ModifyTableDefinitionAddOptionField(
			TableDefinition tableDefinition,
			string          optFieldName,
			SqlDbType       sqlType,
			bool            addFieldIndex
		)
		{
			tableDefinition.AddField(
				new FieldDefinition(
					optFieldName,
					sqlType,
					false,
					false
				)
			);

			if (addFieldIndex)
			{
				tableDefinition.Indexes.Add(
					new IndexDefinition(
						tableDefinition,
						optFieldName + "_indx",
						false,
						optFieldName
					)
				);
			}
		}
Пример #2
0
		internal TableDefinition GetTableDefinition()
		{
			TableDefinition tableDefinition = new TableDefinition(TableName);

			foreach (NormalizeFieldInfo field in Fields)
			{
				tableDefinition.AddField(new FieldDefinition(field.Name, field.Type, field.IsUnique, field.IsNotNull));
			}

			foreach (NormalizeInfo childDirectory in ChildDirectories)
			{
				tableDefinition.AddField(new FieldDefinition(childDirectory.GetAsFk(), SqlDbType.BigInt, true, false));
			}

			if (!string.IsNullOrEmpty(this._tableIndexFields))
			{
				string[] tableIndexFieldsList = this._tableIndexFields.Split(',')
					.Select(x => x.Trim())
					.Where(x => !string.IsNullOrWhiteSpace(x))
					.ToArray();

				tableDefinition.Indexes.Add(
					new IndexDefinition(
						tableDefinition,
						"idx_" + this.TableName + "_config_fields",
						false,
						tableIndexFieldsList
					)
				);
			}

			return tableDefinition;
		}