Exemple #1
0
        public static void DoActionWithLookupList(this SPFieldLookup lookupField, Action <SPList> action)
        {
            if (lookupField == null || action == null)
            {
                return;
            }

            SPWeb lookupWeb = lookupField.GetLookupWeb();

            if (lookupWeb == null)
            {
                return;
            }

            try
            {
                SPList lookupList = lookupField.GetLookupList(lookupWeb);
                action(lookupList);
            }
            finally
            {
                if (lookupWeb != SPContext.Current.Web)
                {
                    lookupWeb.Dispose();
                }
            }
        }