public void AddField(Type type, Type fieldType, string fieldName) { var classInfo = _metaModel.GetClassInfo(type, true); // The real attribute id (-1) will be set in the ci.addAttribute var fullClassName = OdbClassNameResolver.GetFullName(fieldType); var attributeInfo = new ClassAttributeInfo(-1, fieldName, fullClassName, classInfo); classInfo.AddAttribute(attributeInfo); _objectWriter.UpdateClassInfo(classInfo, true); }
internal void AddAttribute(ClassAttributeInfo cai) { cai.SetId(MaxAttributeId++); _attributes.Add(cai); _attributesCache.AttributesByName.Add(cai.GetName(), cai); }
internal void RemoveAttribute(ClassAttributeInfo cai) { _attributes.Remove(cai); _attributesCache.AttributesByName.Remove(cai.GetName()); }
/// <summary> /// Writes a class attribute info, an attribute of a class /// </summary> public void WriteClassAttributeInfo(IStorageEngine storageEngine, ClassAttributeInfo cai, bool writeInTransaction) { FileSystemInterface.WriteInt(cai.GetId(), writeInTransaction); FileSystemInterface.WriteBoolean(cai.IsNative(), writeInTransaction); if (cai.IsNative()) { FileSystemInterface.WriteInt(cai.GetAttributeType().Id, writeInTransaction); if (cai.GetAttributeType().IsArray()) { FileSystemInterface.WriteInt(cai.GetAttributeType().SubType.Id, writeInTransaction); // when the attribute is not native, then write its class info position if (cai.GetAttributeType().SubType.IsNonNative()) { FileSystemInterface.WriteLong( storageEngine.GetSession().GetMetaModel().GetClassInfo( cai.GetAttributeType().SubType.Name, true).ClassInfoId.ObjectId, writeInTransaction); // class info id of array subtype } } // For enum, we write the class info id of the enum class if (cai.GetAttributeType().IsEnum()) { FileSystemInterface.WriteLong( storageEngine.GetSession().GetMetaModel().GetClassInfo(cai.GetFullClassname(), true).ClassInfoId .ObjectId, writeInTransaction); // class info id } } else { FileSystemInterface.WriteLong( storageEngine.GetSession().GetMetaModel().GetClassInfo(cai.GetFullClassname(), true).ClassInfoId. ObjectId, writeInTransaction); // class info id } FileSystemInterface.WriteString(cai.GetName(), writeInTransaction); FileSystemInterface.WriteBoolean(cai.IsIndex(), writeInTransaction); }