Пример #1
0
        /// <summary>
        /// Changes an existing relation's source, destination and ordinal
        /// </summary>
        /// <param name="session"></param>
        /// <param name="originalRelation"></param>
        /// <param name="newSourceId"></param>
        /// <param name="newDestinationId"></param>
        /// <param name="newOrdinal"></param>
        public static void ChangeRelation(this ICoreRelationsRepository session, IRelationById originalRelation, HiveId newSourceId, HiveId newDestinationId, int newOrdinal = int.MinValue)
        {
            session.RemoveRelation(originalRelation);
            var useOrdinal = newOrdinal == int.MinValue ? originalRelation.Ordinal : newOrdinal;

            session.AddRelation(new Relation(originalRelation.Type, newSourceId, newDestinationId, useOrdinal, originalRelation.MetaData.ToArray()));
        }
Пример #2
0
 /// <summary>
 /// Updates a relation to be of a new relation type
 /// </summary>
 /// <param name="session"></param>
 /// <param name="originalRelation"></param>
 /// <param name="newRelationType"></param>
 public static void ChangeRelationType(this ICoreRelationsRepository session, IRelationById originalRelation, RelationType newRelationType)
 {
     session.RemoveRelation(originalRelation);
     session.AddRelation(new Relation(newRelationType, originalRelation.SourceId, originalRelation.DestinationId, originalRelation.Ordinal, originalRelation.MetaData.ToArray()));
 }