Atom
Atom

Reputation: 350

Enumerating Documents in Umbraco

I'm working on some C# code that performs tasks based on certain documents. Currently, I'm using Document[] releaseDocs = Document.GetRootDocuments() and then looping through the results.

Is it possible to do something like Document[] releaseDocs = Document.GetRootDocuments().Where(m => m.Published == false); where I could take advantage of the API to only get Published Documents and Documents with certain set Variables? If so, how, because that method doesn't appear to work.

Upvotes: 1

Views: 85

Answers (2)

Douglas Ludlow
Douglas Ludlow

Reputation: 10922

This should work just fine:

Document[] releaseDocs = Document.GetRootDocuments().Where(m =>
    m.Published == false &&
    m.getProperty("SomeAlias").Value.Equals("Some Value")).ToArray();

Upvotes: 2

Dexter
Dexter

Reputation: 1178

Try something like this:

Document[] documents = Document.GetRootDocuments();

foreach (var doc in documents)
{
    // Do Something
}

Upvotes: 2

Related Questions