title: How to assign a filtered list to another list
body: <p>I need to assign a filtered list to another list, however I do not know the list structure that will filter, just know the parameter for the filter. It Only returns an SPListItemCollection  and I need to return a SPList.</p>
  
  <p>Below follows method in which capture the list, I need to return a list, but filtered by query:</p>
  
  <pre><code>/// &lt;summary&gt;
          /// reads the list to display
          /// &lt;/summary&gt;
          /// &lt;returns&gt;&lt;/returns&gt;
          public SPList GetListFromProjectWorkSpace()
          {
              SPList list = null;
  
              Guid projUID = _helper.GetProjUID();
              if (projUID == Guid.Empty)
              {
                  return list;
              }
  
              // read project data
              IProjectWssInfoDataSet dataset = _service.ReadWssData(projUID);
              if (dataset.ProjWssInfo.Count == 0)
              {
                  return list;
              }
  
              // get workspace name and url
              string workspaceName = dataset.ProjWssInfo[0].WorkspaceName;
              string workspaceUrl = dataset.ProjWssInfo[0].WorkspaceUrl;
  
  
              SPSecurity.RunWithElevatedPrivileges(()=&gt;
              {
                  using (SPSite site = new SPSite(workspaceUrl))
                  {
  
                      for (int i = 0; i &lt; site.AllWebs.Count; i++)
                          {
                              if (!site.AllWebs[i].ServerRelativeUrl.Contains(workspaceName))
                              {
                                  continue;
                              }
  
                              try
                              {
                                  list = site.AllWebs[i].Lists[SelectedList];
  
                              }
                              catch
                              {
                              }
  
  
                          }
  
                          SPQuery query = new SPQuery();
  
                          query.Query = @"&lt;Where&gt;
                                            &lt;Contains&gt;
                                               &lt;FieldRef Name='LinkFilenameNoMenu' /&gt;
                                               &lt;Value Type='Computed'&gt;work&lt;/Value&gt;
                                            &lt;/Contains&gt;
                                         &lt;/Where&gt;";
  
  
  
                          SPListItemCollection  itens = list.Items.List.GetItems(query);
  
                  // I need help here
  
  
  
  
                  }
              });
  
  
              return list;
          }
  </code></pre>
  
  <p>att,</p>
  
  <p>Eduardo </p>