Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will want to use the <a href="http://msdn.microsoft.com/en-us/library/ms457534.aspx" rel="nofollow">GetItems command with an SPQuery object</a>. It is not too complex to sort out with the MS code example below.</p> <pre><code>using System; using Microsoft.SharePoint; namespace Test { class ConsoleApp { static void Main(string[] args) { using (SPSite site = new SPSite("http://localhost")) { using (SPWeb web = site.OpenWeb()) { // Build a query. SPQuery query = new SPQuery(); query.Query = string.Concat( "&lt;Where&gt;&lt;Eq&gt;", "&lt;FieldRef Name='Status'/&gt;", "&lt;Value Type='CHOICE'&gt;Not Started&lt;/Value&gt;", "&lt;/Eq&gt;&lt;/Where&gt;", "&lt;OrderBy&gt;", "&lt;FieldRef Name='DueDate' Ascending='TRUE' /&gt;", "&lt;FieldRef Name=’Priority’ Ascending='TRUE' /&gt;", "&lt;/OrderBy&gt;"); query.ViewFields = string.Concat( "&lt;FieldRef Name='AssignedTo' /&gt;", "&lt;FieldRef Name='LinkTitle' /&gt;", "&lt;FieldRef Name='DueDate' /&gt;", "&lt;FieldRef Name='Priority' /&gt;"); query.ViewFieldsOnly = true; // Fetch only the data that we need. // Get data from a list. string listUrl = web.ServerRelativeUrl + "/lists/tasks"; SPList list = web.GetList(listUrl); SPListItemCollection items = list.GetItems(query); // Print a report header. Console.WriteLine("{0,-25} {1,-20} {2,-25} {3}", "Assigned To", "Task", "Due Date", "Priority"); // Print the details. foreach (SPListItem item in items) { Console.WriteLine("{0,-25} {1,-20} {2,-25} {3}", item["AssignedTo"], item["LinkTitle"], item["DueDate"], item["Priority"]); } } } Console.ReadLine(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload