title: Sharepoint query with elevated privileges
body: <p>A Webpart needs to access a Sharepoint List (read mode). If the user is admin, there isn't problem (works as espected), but if the user hasn't permissions to access, I must use "RunWithElevatedPrivileges" method.</p>
  
  <p>The problem is that seems that the query don't return the correct results. What I'm missing?</p>
  
  <pre><code>        SPList demoList = null;
  
          SPSecurity.RunWithElevatedPrivileges(delegate()
          {
              SPSite oSite = SPControl.GetContextSite(HttpContext.Current); // ADDED
              SPWeb oWeb = oSite.OpenWeb();                                 // ADDED
              demoList = oWeb.Lists["nameList"];
          });
          // demoList has 3 Elements (admin and no admin user) OK
  
          SPListItemCollection collListItems = null;
  
          SPSecurity.RunWithElevatedPrivileges(delegate()
          {
              SPQuery oQuery = new SPQuery() { Query = "&lt;OrderBy&gt;&lt;FieldRef Name='Date' Ascending='False' /&gt;&lt;/OrderBy&gt;" };
              collListItems = demoList.GetItems(oQuery);
          });
  
          // 
          //IF ADMIN
          //collListItems.Count ==&gt;3
  
          //IF NO ADMIN 
          //collListItems.Count ==&gt;0
  </code></pre>