Esempio n. 1
0
        public static Tuple <int, ExpandoObject> ToSyncObject(this SPListItem listItem, ListMapping mapping)
        {
            var result = (IDictionary <string, object>) new ExpandoObject();

            mapping.ListMappingFields.ToList().ForEach(item =>
            {
                var spField = item.ItemName.IsGuid() ? listItem.FieldById(item.ItemName.ToGuid()) : listItem.FieldByName(item.ItemName);
                object spItemValue;
                try {
                    spItemValue = (spField != null) ? listItem.GetObjectValue(spField) : string.Empty;
                } catch {
                    spItemValue = string.Empty;
                }
                result.Add(item.ItemName, spItemValue);
            });
            return(new Tuple <int, ExpandoObject>(listItem.ID, (ExpandoObject)result));
        }