SP2010 get albums and images from Photo Gallery with client object model
I have a photo gallery library. I want to get all albums and their images. Now I get all albums (root level items) with something like this:
ClientContext ctx = new ClientContext(_url);
_mylib = web.Lists.GetByTitle("mylib");
_albums = _list.GetItems(new CamlQuery());
_albums represents albums, on the root of the g开发者_如何学编程allery. How do I get files/items in each of these albums?
mylib
-album1
--image1.jpg
--image2.jpg
-album2
--image1.jpg
...
This was a while ago but thought i'd get in here, add "RecursiveAll" to get through everything, and FSObjType to not include the folders in the list.
The .Include statement allows you to initialize properties you want to access from the list. (The answer on what properties you can access is somewhere here on SO but I can't find the post for the life of me...)
ListItemCollection listItems = null;
List documentsList = ctx.Web.Lists.GetByTitle("mylib");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = @"<View Scope='RecursiveAll'>
<Query>
<Where>
<Eq>
<FieldRef Name='FSObjType' />
<Value Type='int'>1</Value>
</Eq>
</Where>
</Query>
</View>";
listItems = documentsList.GetItems(camlQuery);
ctx.Load(
listItems,
items => items
.Include(
item => item["ID"]
));
ctx.ExecuteQuery();
精彩评论