Ejemplo n.º 1
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Creates relationship core.
        /// </summary>
        /// <param name="id">
        ///  The identifier.
        /// </param>
        /// <param name="relationshipSchema">
        ///  The relationship schema.
        /// </param>
        /// <param name="start">
        ///  the start.
        /// </param>
        /// <param name="endId">
        ///  The end identifier.
        /// </param>
        /// <param name="relationship">
        ///  The relationship.
        /// </param>
        /// <returns>
        ///  The new relationship core.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        protected virtual IModelRelationship CreateRelationshipCore(Identity id, ISchemaRelationship relationshipSchema, IModelElement start, Identity endId, IModelRelationship relationship)
        {
            Contract.Requires(id, "id");
            Contract.Requires(relationshipSchema, "relationshipSchema");
            Contract.Requires(start, "start");
            Contract.Requires(endId, "endId");

            CheckInitialized();
            using (var session = EnsuresRunInSession())
            {
                relationship = L1Cache.CreateRelationship(id, relationshipSchema, start, endId, relationship);

                if (session != null)
                {
                    session.AcceptChanges();
                }
                return(relationship);
            }
        }