System.Data.DataRelationCollection.Clear C# (CSharp) Method

Clear() public method

Clears the collection of any relations.
public Clear ( ) : void
return void
        public virtual void Clear()
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataRelationCollection.Clear|API> {0}", ObjectID);
            try
            {
                int count = Count;
                OnCollectionChanging(s_refreshEventArgs);
                for (int i = count - 1; i >= 0; i--)
                {
                    _inTransition = this[i];
                    RemoveCore(_inTransition);
                }
                OnCollectionChanged(s_refreshEventArgs);
                _inTransition = null;
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }

Usage Example

        private uint Pop(CUQueue UQueue, ref DataRelationCollection drc)
        {
            int n;
            string str;
            bool b;
            int nData;
            uint nSize = UQueue.GetSize();
            UQueue.Load(out nData);
            drc.Clear();
            for (n = 0; n < nData; n++)
            {
                DataColumn[] dcsChild = null;
                PopTableColNamesOnly(UQueue, ref dcsChild);

                UQueue.Load(out b);
                UQueue.Load(out str);

                DataColumn[] dcsParent = null;
                PopTableColNamesOnly(UQueue, ref dcsParent);

                DataRelation dr = new DataRelation(str, dcsParent, dcsChild);
                dr.Nested = b;
                drc.Add(dr);
            }
            return (nSize - UQueue.GetSize());
        }