コード例 #1
0
        private string _parentPropertyName;   // Property name for this type on the containing object

        /// <summary>
        /// Associate the ComplexType with an Entity or another ComplexObject
        /// Parent may be an Entity or ComplexObject
        /// </summary>
        /// <param name="parent">Object to be added to.</param>
        /// <param name="parentPropertyName">The property on the parent that reference the complex type.</param>
        internal void AttachToParent(
            StructuralObject parent,
            string parentPropertyName)
        {
            Debug.Assert(null != parent, "Attempt to attach to a null parent");
            Debug.Assert(null != parentPropertyName, "Must provide parentPropertyName in order to attach");

            if (_parent != null)
            {
                throw EntityUtil.ComplexObjectAlreadyAttachedToParent();
            }

            Debug.Assert(_parentPropertyName == null);

            _parent             = parent;
            _parentPropertyName = parentPropertyName;
        }