The usual way of getting the list of fields from the content type doesn’t work because the content type is null in that kind of items…
The answer, my friend, is sitting in the Xml.
static List<string> ExcludedFields = new List<string> { "z", "ows_ServerRedirected", "ows_FileRef", "ows_PermMask", "ows_FSObjType", "ows__Level", "ows__ModerationStatus" }; /// <summary> /// Gets a dictionary with the available fields and its values. /// </summary> public static Dictionary<string, string> getAvailableFields(this SPListItem item) { XElement row = XElement.Parse(item.Xml); Dictionary<string, string> Fields = new Dictionary<string, string>(); foreach (XAttribute field in row.Attributes()) { if (!ExcludedFields.Contains(field.Name.LocalName)) Fields.Add(field.Name.LocalName.Substring(4), field.Value); } return Fields; }
Using this I have been able to reduce the traffic on a web service method in a 65%.
No comments:
Post a Comment