{"id":910,"date":"2012-03-13T19:12:06","date_gmt":"2012-03-13T19:12:06","guid":{"rendered":"http:\/\/www.stuartroberts.net\/?p=910"},"modified":"2012-03-13T19:40:53","modified_gmt":"2012-03-13T19:40:53","slug":"quick-tip-6","status":"publish","type":"post","link":"https:\/\/www.stuartroberts.net\/index.php\/2012\/03\/13\/quick-tip-6\/","title":{"rendered":"Get List Items by Field Value"},"content":{"rendered":"<p><strong>SharePoint Short #6<\/strong><br \/>\nTo retrieve all <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/microsoft.sharepoint.splistitem.aspx\" title=\"SPListItem\" target=\"_blank\">SPListItem<\/a> objects that have a specified field value, instead of writing a CAML query, use the following LINQ statement:<\/p>\n<pre lang=\"csharp\">\r\npublic List<SPListItem>  GetItemsContainingValue(SPList list, Guid fieldId, string match)\r\n{\r\n    List<SPListItem> matchingItems =\r\n        (from SPListItem listItem in list.Items\r\n         where\r\n             listItem.Fields.Contains(fieldId) &&\r\n             listItem[fieldId] != null &&\r\n             listItem[fieldId].ToString().Equals(match, StringComparison.InvariantCultureIgnoreCase)\r\n         select listItem).ToList<SPListItem>();\r\n\r\n    return matchingItems;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SharePoint Short #6 To retrieve all SPListItem objects that have a specified field value, instead of writing a CAML query, use the following LINQ statement: public List GetItemsContainingValue(SPList list, Guid fieldId, string match) { List matchingItems = (from SPListItem listItem &hellip; <a href=\"https:\/\/www.stuartroberts.net\/index.php\/2012\/03\/13\/quick-tip-6\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[44],"tags":[81,45],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/plx2I-eG","_links":{"self":[{"href":"https:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts\/910"}],"collection":[{"href":"https:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/comments?post=910"}],"version-history":[{"count":7,"href":"https:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts\/910\/revisions"}],"predecessor-version":[{"id":936,"href":"https:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts\/910\/revisions\/936"}],"wp:attachment":[{"href":"https:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/media?parent=910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/categories?post=910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/tags?post=910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}