private void CreateField(Namespace root, Entity tableType, Entity propertyType) { Entity entity = new Entity() { Namespace = root, Name = "Field", Alias = "Поле таблицы СУБД объекта метаданных", Code = 6, IsSealed = false, IsAbstract = false }; entity.Save(); Table table = new Table() { Entity = entity, Schema = "metadata", Name = "fields", Purpose = TablePurpose.Main }; table.Save(); AddIdentityProperty(entity, table); AddVersionProperty(entity, table); AddStringProperty(entity, table, 2, "Name", "name", 100); AddObjectProperty(entity, table, 3, "Table", tableType, "table"); AddObjectProperty(entity, table, 4, "Property", propertyType, "property"); AddIntegerProperty(entity, table, 5, "Purpose", "purpose"); AddStringProperty(entity, table, 6, "TypeName", "type_name", 16); AddIntegerProperty(entity, table, 7, "Length", "length"); AddIntegerProperty(entity, table, 8, "Precision", "precision"); AddIntegerProperty(entity, table, 9, "Scale", "scale"); AddBooleanProperty(entity, table, 10, "IsNullable", "is_nullable"); AddBooleanProperty(entity, table, 11, "IsPrimaryKey", "is_primary_key"); Property property = new Property() { Entity = entity, Ordinal = 12, Name = "KeyOrdinal", IsReadOnly = false, IsPrimaryKey = false, IsAbstract = false, Purpose = PropertyPurpose.Property }; property.Save(); Relation relation = new Relation() { Property = property, Entity = Entity.Byte }; relation.Save(); Field field = new Field() { Property = property, Table = table, Name = "key_ordinal", TypeName = "tinyint", IsNullable = false, IsPrimaryKey = false, KeyOrdinal = 0, Length = 1, Scale = 0, Precision = 3, Purpose = FieldPurpose.Value }; field.Save(); }
private void CreateRelation(Namespace root, Entity propertyType, Entity entityType) { Entity entity = new Entity() { Namespace = root, Name = "Relation", Alias = "Допустимые для свойства объекта типы данных", Code = 7, IsSealed = false, IsAbstract = false }; entity.Save(); Table table = new Table() { Entity = entity, Schema = "metadata", Name = "relations", Purpose = TablePurpose.Main }; table.Save(); Property property = new Property() { Entity = entity, Ordinal = 1, Name = "Property", IsReadOnly = false, IsPrimaryKey = true, IsAbstract = false, Purpose = PropertyPurpose.Property }; property.Save(); Relation relation = new Relation() { Property = property, Entity = propertyType }; relation.Save(); Field field = new Field() { Property = property, Table = table, Name = "property", TypeName = "uniqueidentifier", IsNullable = false, IsPrimaryKey = true, KeyOrdinal = 1, Length = 16, Scale = 0, Precision = 0, Purpose = FieldPurpose.Object }; field.Save(); property = new Property() { Entity = entity, Ordinal = 2, Name = "Entity", IsReadOnly = false, IsPrimaryKey = true, IsAbstract = false, Purpose = PropertyPurpose.Property }; property.Save(); relation = new Relation() { Property = property, Entity = entityType }; relation.Save(); field = new Field() { Property = property, Table = table, Name = "entity", TypeName = "uniqueidentifier", IsNullable = false, IsPrimaryKey = true, KeyOrdinal = 2, Length = 16, Scale = 0, Precision = 0, Purpose = FieldPurpose.Object }; field.Save(); }
private Entity CreateNamespace(Namespace root, Entity infoBase) { Entity entity = new Entity() { Namespace = root, Name = "Namespace", Alias = "Пространство имён", Code = 2, IsSealed = false, IsAbstract = false }; entity.Save(); Table table = new Table() { Entity = entity, Schema = "metadata", Name = "namespaces", Purpose = TablePurpose.Main }; table.Save(); AddIdentityProperty(entity, table); AddVersionProperty(entity, table); AddStringProperty(entity, table, 2, "Name", "name", 100); Property property = new Property() { Entity = entity, Ordinal = 3, Name = "Owner", IsReadOnly = false, IsPrimaryKey = false, IsAbstract = false, Purpose = PropertyPurpose.Property }; property.Save(); Relation relation = new Relation() { Property = property, Entity = infoBase }; relation.Save(); relation = new Relation() { Property = property, Entity = entity }; relation.Save(); Field field = new Field() { Property = property, Table = table, Name = "owner", TypeName = "uniqueidentifier", IsNullable = false, IsPrimaryKey = false, KeyOrdinal = 0, Length = 16, Scale = 0, Precision = 0, Purpose = FieldPurpose.Object }; field.Save(); field = new Field() { Property = property, Table = table, Name = "owner_", TypeName = "int", IsNullable = false, IsPrimaryKey = false, KeyOrdinal = 0, Length = 4, Scale = 0, Precision = 10, Purpose = FieldPurpose.TypeCode }; field.Save(); return(entity); }