Beispiel #1
0
        /// <summary>
        /// Adds a root entity to which other entities may be in relationship.
        /// </summary>
        public void Add(IEntity entity)
        {
            var ce = ContextEntity.Create <NullRelationship>(entity, NullEntity.Instance);

            entities.Add(ce);
            ValidateContextDeclaration(entity, () => entities.Remove(ce));
            ValidateRelationshipDeclaration <NullRelationship>(entity, NullEntity.Instance, () => entities.Remove(ce));
        }
Beispiel #2
0
        /// <summary>
        /// Adds a target entity that has the specified relationship to the source entitiy.
        /// </summary>
        public void Add <R>(IEntity target, IEntity source) where R : IRelationship
        {
            ValidateRelationship <R>(target, source);
            var ce = ContextEntity.Create <R>(target, source);

            entities.Add(ce);
            ValidateContextDeclaration(target, () => entities.Remove(ce));
            ValidateRelationshipDeclaration <R>(target, source, () => entities.Remove(ce));
        }