/// <summary> /// Maps the given <paramref name="dbRecord"/> to <paramref name="properties"/>. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="dbRecord">The <see cref="DbRecord"/> which to map.</param> /// <param name="properties">The <see cref="IPropertyBag"/> in which to store the mapped result.</param> protected override void DoMap(IMansionContext context, DbRecord dbRecord, IPropertyBag properties) { // field indices var idIndex = dbRecord.GetOrdinal("id"); // set the pointer properties.Set("id", dbRecord.GetInt32(idIndex)); }
/// <summary> /// Maps the given <paramref name="dbRecord"/> to <paramref name="properties"/>. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="dbRecord">The <see cref="DbRecord"/> which to map.</param> /// <param name="properties">The <see cref="IPropertyBag"/> in which to store the mapped result.</param> protected override void DoMap(IMansionContext context, DbRecord dbRecord, IPropertyBag properties) { // field indices var idIndex = dbRecord.GetOrdinal("id"); var parentPointerIndex = dbRecord.GetOrdinal("parentPointer"); var nameIndex = dbRecord.GetOrdinal("name"); var parentPathIndex = dbRecord.GetOrdinal("parentPath"); var typeIndex = dbRecord.GetOrdinal("type"); var parentStructureIndex = dbRecord.GetOrdinal("parentStructure"); // assemble the node pointer var pointer = (dbRecord.IsDBNull(parentPointerIndex) ? string.Empty : dbRecord.GetString(parentPointerIndex) + NodePointer.PointerSeparator) + dbRecord.GetInt32(idIndex); var structure = (dbRecord.IsDBNull(parentStructureIndex) ? string.Empty : dbRecord.GetString(parentStructureIndex) + NodePointer.StructureSeparator) + dbRecord.GetString(typeIndex); var path = (dbRecord.IsDBNull(parentPathIndex) ? string.Empty : dbRecord.GetString(parentPathIndex) + NodePointer.PathSeparator) + dbRecord.GetString(nameIndex); var nodePointer = NodePointer.Parse(pointer, structure, path); // set the pointer properties.Set("pointer", nodePointer); properties.Set("path", nodePointer.PathString); properties.Set("structure", nodePointer.StructureString); properties.Set("depth", nodePointer.Depth); properties.Set("name", nodePointer.Name); properties.Set("type", nodePointer.Type); if (nodePointer.HasParent) { properties.Set("parentPointer", nodePointer.Parent); properties.Set("parentId", nodePointer.Parent.Id); } }
/// <summary> /// Maps the given <paramref name="dbRecord"/> to <paramref name="properties"/>. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="dbRecord">The <see cref="DbRecord"/> which to map.</param> /// <param name="properties">The <see cref="IPropertyBag"/> in which to store the mapped result.</param> protected override void DoMap(IMansionContext context, DbRecord dbRecord, IPropertyBag properties) { // get the index of the column var extendedPropertiesIndex = dbRecord.GetOrdinal("extendedProperties"); // check if there are no extended properties if (dbRecord.IsDBNull(extendedPropertiesIndex)) return; // get the extended properties var extendedPropertiesLength = dbRecord.GetBytes(extendedPropertiesIndex, 0, null, 0, 0); var serializedProperties = new byte[extendedPropertiesLength]; dbRecord.GetBytes(extendedPropertiesIndex, 0, serializedProperties, 0, serializedProperties.Length); // deserialize var deserializedProperties = conversionService.Convert<IPropertyBag>(context, serializedProperties); // merge the deserialized properties properties.Merge(deserializedProperties); }