Пример #1
0
        /// <summary>
        /// Inserts the specified name/value pairs into the
        /// relationship defined by the <cref name="ReferenceMember"/> property.
        /// </summary>
        /// <param name="links">A collection of business objects.</param>
        /// <param name="values">A collection of name/value pairs to insert.</param>
        protected void InsertReference(IList links, IDictionary values)
        {
            Object entityKeyValue = PrimaryMember.GetEntityId();

            // delayed insert
            if (ReferenceMember.HasDataSource && entityKeyValue == null)
            {
                ReferenceMember.Inserts.Add(values);
            }
            else
            {
                Insert(ReferenceMember, links, values, true);
            }
        }
Пример #2
0
        /// <summary>
        /// Inserts any previously cached business object references.
        /// </summary>
        /// <param name="member">The relationship member.</param>
        private void Insert(EntityRelationshipMember member)
        {
            if (member != null && member.HasDataSource)
            {
                Object entityKeyValue = PrimaryMember.GetEntityId();

                foreach (IDictionary values in member.Inserts)
                {
                    values[member.EntityKeyName] = entityKeyValue;
                    member.GetLinkedDataSource().Insert(values);
                }

                member.Inserts.Clear();
            }
        }
Пример #3
0
        /// <summary>
        /// Inserts the specified <paramref name="foreignKeyValue"/> into the
        /// collection of business objects.
        /// </summary>
        /// <param name="links">A collection of business objects.</param>
        /// <param name="foreignKeyValue">The value to insert.</param>
        protected void InsertLink(IList links, Object foreignKeyValue)
        {
            // make sure link doesn't exist
            Object link = EntityUtil.GetEntity(links, LinkMember.ForeignKeyName, foreignKeyValue);

            if (link == null)
            {
                Object entityKeyValue = PrimaryMember.GetEntityId();

                IDictionary values = new Hashtable();
                values.Add(LinkMember.EntityKeyName, entityKeyValue);
                values.Add(LinkMember.ForeignKeyName, foreignKeyValue);

                // delayed insert
                if (LinkMember.HasDataSource && entityKeyValue == null)
                {
                    LinkMember.Inserts.Add(values);
                }
                else
                {
                    Insert(LinkMember, links, values);
                }
            }
        }