Solución: SPQuery non busca Folders

This past week I was implementing an "evolving" solution for a client that uses BDC and SPQuery and ran into some difficulty using SPQuery against a document library containing folders. Bottom line: assign "recursive" ao atributo de vista da consulta.

O meu escenario:

  • O luns, Eu enviar un documento e ofrecer algúns datos de meta.
  • A semana seguinte,, I upload a new document. Much of this new document’s meta data is based on the document I uploaded on Monday (which we call the "master document").
  • Creamos unha fachada de servizo web que ofrece unha interface BDC-friendly para a lista para que os usuarios poidan facilmente atopar ese documento luns a través dunha investigación de título.
  • A BDC data column provides a friendly user interface. (Iso forma parte da miña tentativa de usar BDC para unha columna de investigación máis agradable).

A final BDC servizo fachada utiliza unha consulta como esta a facer o lookup:

 // Usado U2U ferramenta para auxiliar na xeración de esta consulta CAML.
      oQuery.Query =
        "<Onde>";

      se (titleFilter.Length > 0)
        oQuery.Query  =
          "  <E>";

      oQuery.Query  =
        "    <E>" +
        "      <Geq>" +
        "        <FieldRef Name=\"DocumentId\" />" +
        "        <Value Type=\"Text\">" + MiniD + "</Valor>" +
        "      </Geq>" +
        "      <Leq>" +
        "        <FieldRef Name=\"DocumentId\" />" +
        "        <Value Type=\"Text\">" + maxId + "</Valor>" +
        "      </Leq>" +
        "    </E>";

      se (titleFilter.Length > 0)
        oQuery.Query  =
          "    <Contén>" +
          "      <FieldRef Name=\"Title\" />" +
          "      <Value Type=\"Text\">" + titleFilter + "</Valor>" +
          "    </Contén>" +
          "  </E>";
      oQuery.Query  =
        "</Onde>";

Durante a fase inicial de desenvolvemento, this worked great. Con todo, nós introducimos cartafoles no directorio para resolver algúns problemas e, de súpeto, my BDC picker wouldn’t return any results. I tracked this down to the fact that the SPQuery would never return any results. We used folders primarily to allow multiple files with the same name to be uploaded but with different meta data. When the file is uploaded, creamos un cartafol con base na identificación do elemento da lista e move o ficheiro alí (Eu escribín sobre iso aquí; tivemos resultados mixtos con esta visión, pero en xeral, el funciona ben). The user don’t care about folders and in fact, don’t really understand that there are any folders. We have configured all the views on the library to show items without regard to folders.

I hit this problem twice as the technical implementation evolved and solved it differently each time. The first time, I wasn’t using the CONTAINS operator in the query. Without a CONTAINS operator, I was able to solve the problem by specifying the view on the SPQuery’s contructor. Instead of using the default constructor:

SPList oList = web.Lists["Documents"];

SPQuery oQuery = novo SPQuery();

Eu en vez utilizar un constructor que especificou unha vista:

SPList oList = web.Lists["Documents"];

SPQuery oQuery = novo SPQuery(oList.Views["All Documents"]);

Isto resolveu o problema e comece a poñer os meus resultados.

I then added the CONTAINS operator into the mix and it broke again. It turns out that the CONTAINS operator, tan lonxe como podo dicir, non funciona co punto de vista do mesmo xeito que a un simple geq / LEQ operators. I did some searching and learned that the query’s ViewAttributes should be set to "Recursive", como no:

oQuery.ViewAttributes = "Scope=\"Recursive\"";

That solved the problem for CONTAINS. En realidade, Isto tamén resolveu o meu problema de investigación orixinal e se eu tivese especificar o atributo recursivo por primeira vez, Eu non tería corrido para a cuestión de novo.

O feito de que un SPQuery visión baseada funciona para algúns operadores (GEQ/LEQ) e non outros (Contén), xunto co feito de que KPIs non parecen traballar en conxunto con bibliotecas de documentos cartafol contén me leva a pensar que SPQuery ten algúns problemas de ortogonalidade.

Agradecementos especiais:

  • O persoal da U2U ea súa ferramenta de consulta.
  • Michael Hoffer de gran "learning by doing" blog, comentarios e respostas.

</final>

Rexístrate para o meu blog!

3 pensamentos sobre "Solución: SPQuery non busca Folders

  1. Ningún nome

    http://www.batteryfast.co.uk/asus/w3v.htm asus W3V batería,
    http://www.batteryfast.co.uk/asus/w3000a.htm asus w3000a battery,
    http://www.batteryfast.co.uk/asus/w3000.htm Asus W3000 batería,
    http://www.batteryfast.co.uk/asus/w3000v.htm asus w3000v batería,
    http://www.batteryfast.co.uk/asus/a31-s5.htm asus a31-S5 batería,
    http://www.batteryfast.co.uk/asus/a32-s5.htm asus a32-S5 batería,
    http://www.batteryfast.co.uk/asus/s52n.htm asus s52n batería,
    http://www.batteryfast.co.uk/asus/s5000.htm asus s5000 batería,
    http://www.batteryfast.co.uk/asus/s5200n.htm asus s5200n batería,
    http://www.batteryfast.co.uk/asus/s5n.htm asus S5N batería,
    http://www.batteryfast.co.uk/asus/90-naa1b1000.htm asus 90 naa1b1000 batería,
    http://www.batteryfast.co.uk/asus/s2691061.htm asus s2691061 batería,
    http://www.batteryfast.co.uk/asus/a42-v6.htm Asus A42-v6 batería,
    http://www.batteryfast.co.uk/asus/a32-u5.htm Asus A32-U5 batería,
    http://www.batteryfast.co.uk/asus/u5f.htm asus U5F batería,
    http://www.batteryfast.co.uk/asus/u5a.htm asus batería U5A,
    http://www.batteryfast.co.uk/asus/u5f.htm asus U5F batería,
    http://www.batteryfast.co.uk/asus/u5.htm ASUS U5 batería,
    http://www.batteryfast.co.uk/compaq/nw8000.htm Compaq nw8000 batería,
    http://www.batteryfast.co.uk/compaq/nc8000.htm Compaq nc8000 batería,
    http://www.batteryfast.co.uk/compaq/v1000.htm Compaq batería V1000,
    http://www.batteryfast.co.uk/compaq/nc6000.htm Compaq nc6000 batería,
    http://www.batteryfast.co.uk/compaq/nx5000.htm Compaq nx5000 da batería,
    http://www.batteryfast.co.uk/compaq/n600.htm n600 batería Compaq,
    http://www.batteryfast.co.uk/compaq/n600c.htm Compaq N600C batería,
    http://www.batteryfast.co.uk/compaq/n610c.htm Compaq N610C batería,
    http://www.batteryfast.co.uk/compaq/n610v.htm Compaq n610v batería,
    http://www.batteryfast.co.uk/compaq/n620c.htm Compaq N620c batería,
    http://www.batteryfast.co.uk/compaq/e500.htm Compaq e500 batería,
    http://www.batteryfast.co.uk/compaq/e500s.htm Compaq E500S batería,
    http://www.batteryfast.co.uk/compaq/v300.htm v300 batería Compaq,
    http://www.batteryfast.co.uk/compaq/v500.htm v500 batería Compaq,
    http://www.batteryfast.co.uk/compaq/pp2060.htm Compaq pp2060 batería,
    http://www.batteryfast.co.uk/compaq/nx9000.htm Compaq NX9000 batería,
    http://www.batteryfast.co.uk/compaq/nx9005.htm Compaq NX9005 batería,
    http://www.batteryfast.co.uk/compaq/nx9010.htm Compaq NX9010 batería,
    http://www.batteryfast.co.uk/compaq/nx9020.htm Compaq nx9020 da batería,
    http://www.batteryfast.co.uk/compaq/n110.htm n110 batería Compaq,
    http://www.batteryfast.co.uk/compaq/n110s.htm Compaq n110s batería,
    http://www.batteryfast.co.uk/compaq/pp2101x.htm Compaq pp2101x batería,
    http://www.batteryfast.co.uk/compaq/presario-2100.htm Compaq Presario 2100 batería,
    http://www.batteryfast.co.uk/compaq/ze4000.htm Compaq ze4000 batería,
    http://www.batteryfast.co.uk/compaq/f4809a.htm Compaq F4809A batería,
    http://www.batteryfast.co.uk/compaq/f4812a.htm Compaq F4812A batería,
    http://www.batteryfast.co.uk/dell/inspiron-700m.htm Dell Inspiron 700m batería,
    http://www.batteryfast.co.uk/dell/inspiron-710m.htm Dell Inspiron 710m batería,
    http://www.batteryfast.co.uk/dell/latitude-x200.htm dell latitude x200 batería,
    http://www.batteryfast.co.uk/dell/8u443.htm Dell batería 8u443,
    http://www.batteryfast.co.uk/dell/312-0058.htm Dell 312-0058 batería,

    Responder

Deixe unha resposta

Enderezo de correo electrónico non será publicado. Os campos obrigatorios están marcados *