title: How to get a document on Sharepoint by its unique ID?
body: <p>I am trying to achieve the following using the Sharepoint Client Object Model (CSOM) on a Sharepoint Online Instance:</p>
  
  <ul>
  <li>Perform a keyword query on the entire side</li>
  <li>Store some field value which uniquely identifies a search result (a row in the <code>SharepointResultTable</code> returned by the query</li>
  <li>Retrieve the same information as provided in the row of the result table at a later point or somewhere else (this is when I don't have the result table anymore) using this stored field value.</li>
  </ul>
  
  <p>In pseudo code:</p>
  
  <pre><code>var results = Sharepoint.GetSearchResults("Keyword");
  var specificItem = results[2];
  var itemId = sepcificItem.UniqueId;
  Store(itemId);
  </code></pre>
  
  <p>And later:</p>
  
  <pre><code>var itemId = LoadItemId();
  var item = Sharepoint.GetItem(itemId);
  </code></pre>
  
  <p>The querying part is working fine, I get a search result table offering lots of field values for each result, such as different URLs and also unique identifiers, titles, etc.</p>
  
  <pre><code>var clientContext = new ClientContext(SharepointUri);
  clientContext.Credentials = new SharePointOnlineCredentials(SharepointUserName, GetSecureString(SharepointPassword));
  var keywordQuery = new KeywordQuery(clientContext);
  keywordQuery.QueryText = keyword;
  var searchExecutor = new SearchExecutor(clientContext);
  var sharepointResultTable = searchExecutor.ExecuteQuery(keywordQuery);
  clientContext.ExecuteQuery();
  foreach (var resultRow in sharepointResultTable.Value[0].ResultRows)
  {
      var path = (string) resultRow["ServerRedirectedURL"];
      var id = Guid.Parse((string) resultRow["UniqueId"]);        
  }
  </code></pre>
  
  <p>The part I am missing now is: <strong>Which value(s) should I store for a result row and how can I perform an <em>efficient</em> query based on this data to get the item later?</strong> (Of course I could just perform a query with the same keyword again, but as I know the id or whatever I've stored, there must be more efficient ways. Also, the item might not be a result of the former keyword anymore because it might have changed).</p>
  
  <p>I've tried this, using the id in the result table column 'UniqueId':</p>
  
  <pre><code>var clientContext = new ClientContext(SharepointUri);
  clientContext.Credentials = new SharePointOnlineCredentials(SharepointUserName, GetSecureString(SharepointPassword));
  var file = clientContext.Web.GetFileById(location);
  clientContext.ExecuteQuery();
  Console.WriteLine(file.Name);
  return true;
  </code></pre>
  
  <p>It doesn't work, though:</p>
  
  <blockquote>
    <p>Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException:
    The property or field 'Name' has not been initialized. It has not been
    requested or the request has not been executed. It may need to be
    explicitly requested.</p>
  </blockquote>
  
  <p>and honestly, I don't know what I'm doing here, because it's really hard to tell for me what the various Id's mean (DocId, WorkId, UniqueId, just to mention three...).</p>
  
  <p>Can anybody with a little more Sharepoint experience tell me the way here?</p>