Oplossing: SPQuery soek nie na dopgehou

Die afgelope week het ek die implementering van 'n "ontwikkelende" solution for a client that uses BDC and SPQuery and ran into some difficulty using SPQuery against a document library containing folders. Bottom line: wys "rekursiewe" die oog kenmerk van die navraag.

My scenario:

  • Op Maandag, Ek laai 'n dokument en verskaf 'n meta data.
  • Die volgende week, I upload a new document. Much of this new document’s meta data is based on the document I uploaded on Monday (wat ons noem die "meester-dokument").
  • Ons het 'n web fasade wat 'n BDC-vriendelike koppelvlak tot die lys sodat gebruikers kan maklik deur middel van 'n titel te soek wat Maandag-dokument vind.
  • A BDC data column provides a friendly user interface. (Dit is deel van my poging om by die gebruik van BDC vir 'n meer vriendelike Lookup kolom).

Die finale BDC gevel diens gebruik 'n navraag, soos die soek om te doen.:

 // U2U hulpmiddel om te help in die opwekking van hierdie CAML navraag.
      oQuery.Query =
        "<Waar>";

      indien (titleFilter.Length > 0)
        oQuery.Query   =
          "  <En>";

      oQuery.Query   =
        "    <En>" +
        "      <Geq>" +
        "        <FieldRef Naam =  "DocumentId " />" +
        "        <Waarde Tipe =  "teks ">" + MinID + "</Waarde>" +
        "      </Geq>" +
        "      <Leq>" +
        "        <FieldRef Naam =  "DocumentId " />" +
        "        <Waarde Tipe =  "teks ">" + maxId + "</Waarde>" +
        "      </Leq>" +
        "    </En>";

      indien (titleFilter.Length > 0)
        oQuery.Query   =
          "    <Bevat>" +
          "      <FieldRef Naam =  "Titel " />" +
          "      <Waarde Tipe =  "teks ">" + titleFilter + "</Waarde>" +
          "    </Bevat>" +
          "  </En>";
      oQuery.Query   =
        "</Waar>";

Gedurende die eerste fase van die ontwikkeling, this worked great. Egter, ons bekendgestel dopgehou in die gids 'n paar probleme op te los en skielik, 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, ons 'n gids skep wat gebaseer is op die lys-item se ID en dan beweeg die lêer daar (Ek het geskryf oor hier; ons het gemengde resultate met hierdie benadering nie, maar oor die algemeen, dit goed werk). 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["Dokumente"];

SPQuery oQuery = nuwe SPQuery();

Ek plaas 'n konstruktor wat die oog gespesifiseer:

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

SPQuery oQuery = nuwe SPQuery(oList.Views["Alle dokumente"]);

Dit is die probleem opgelos het en ek het my resultate te kry.

I then added the CONTAINS operator into the mix and it broke again. It turns out that the CONTAINS operator, so ver as wat ek kan sê, nie werk nie met die oog op dieselfde wyse as die van 'n eenvoudiger GEQ / LEQ operators. I did some searching and learned that the query’s ViewAttributes should be set to "Recursive", soos in:

oQuery.ViewAttributes = "Scope = " Rekursiewe "";

That solved the problem for CONTAINS. In werklikheid, dit is ook my oorspronklike soek probleem opgelos en as ek het vermeld die rekursiewe kenmerk die eerste keer, Ek wil nie gehardloop het nie weer in die saak.

Die feit dat 'n oog-gebaseerde SPQuery werk vir sommige operateurs (GEQ / LEQ) en ander nie (BEVAT), tesame met die feit dat KPI's nie lyk te alle saam met die gids-bevattende dokument biblioteke, lei my om te glo dat SPQuery het 'n paar ortogonaliteit kwessies.

Spesiale dank:

  • Die goeie mense by U2U en hulle navraag instrument.
  • Michael Hoffer se groot "leer deur te doen" blog post, kommentaar en antwoorde.

</einde>

Skryf in op my blog!

3 gedagtes oor "Oplossing: SPQuery soek nie na dopgehou

  1. Geen naam

    http://www.batteryfast.co.uk/asus/w3v.htm asus w3v battery,
    http://www.batteryfast.co.uk/asus/w3000a.htm asus w3000a battery,
    http://www.batteryfast.co.uk/asus/w3000.htm asus w3000 battery,
    http://www.batteryfast.co.uk/asus/w3000v.htm asus w3000v battery,
    http://www.batteryfast.co.uk/asus/a31-s5.htm asus a31-s5 battery,
    http://www.batteryfast.co.uk/asus/a32-s5.htm asus a32-s5 battery,
    http://www.batteryfast.co.uk/asus/s52n.htm asus s52n battery,
    http://www.batteryfast.co.uk/asus/s5000.htm asus s5000 battery,
    http://www.batteryfast.co.uk/asus/s5200n.htm asus s5200n battery,
    http://www.batteryfast.co.uk/asus/s5n.htm asus s5n battery,
    http://www.batteryfast.co.uk/asus/90-naa1b1000.htm asus 90-naa1b1000 battery,
    http://www.batteryfast.co.uk/asus/s2691061.htm asus s2691061 battery,
    http://www.batteryfast.co.uk/asus/a42-v6.htm asus a42-v6 battery,
    http://www.batteryfast.co.uk/asus/a32-u5.htm asus a32-u5 battery,
    http://www.batteryfast.co.uk/asus/u5f.htm asus u5f battery,
    http://www.batteryfast.co.uk/asus/u5a.htm asus u5a battery,
    http://www.batteryfast.co.uk/asus/u5f.htm asus u5f battery,
    http://www.batteryfast.co.uk/asus/u5.htm asus u5 battery,
    http://www.batteryfast.co.uk/compaq/nw8000.htm compaq nw8000 battery,
    http://www.batteryfast.co.uk/compaq/nc8000.htm compaq nc8000 battery,
    http://www.batteryfast.co.uk/compaq/v1000.htm compaq v1000 battery,
    http://www.batteryfast.co.uk/compaq/nc6000.htm compaq nc6000 battery,
    http://www.batteryfast.co.uk/compaq/nx5000.htm compaq nx5000 battery,
    http://www.batteryfast.co.uk/compaq/n600.htm compaq n600 battery,
    http://www.batteryfast.co.uk/compaq/n600c.htm compaq n600c battery,
    http://www.batteryfast.co.uk/compaq/n610c.htm compaq n610c battery,
    http://www.batteryfast.co.uk/compaq/n610v.htm compaq n610v battery,
    http://www.batteryfast.co.uk/compaq/n620c.htm compaq n620c battery,
    http://www.batteryfast.co.uk/compaq/e500.htm compaq e500 battery,
    http://www.batteryfast.co.uk/compaq/e500s.htm compaq e500s battery,
    http://www.batteryfast.co.uk/compaq/v300.htm compaq v300 battery,
    http://www.batteryfast.co.uk/compaq/v500.htm compaq v500 battery,
    http://www.batteryfast.co.uk/compaq/pp2060.htm compaq pp2060 battery,
    http://www.batteryfast.co.uk/compaq/nx9000.htm compaq nx9000 battery,
    http://www.batteryfast.co.uk/compaq/nx9005.htm compaq nx9005 battery,
    http://www.batteryfast.co.uk/compaq/nx9010.htm compaq nx9010 battery,
    http://www.batteryfast.co.uk/compaq/nx9020.htm compaq nx9020 battery,
    http://www.batteryfast.co.uk/compaq/n110.htm compaq n110 battery,
    http://www.batteryfast.co.uk/compaq/n110s.htm compaq n110s battery,
    http://www.batteryfast.co.uk/compaq/pp2101x.htm compaq pp2101x battery,
    http://www.batteryfast.co.uk/compaq/presario-2100.htm compaq presario 2100 battery,
    http://www.batteryfast.co.uk/compaq/ze4000.htm compaq ze4000 battery,
    http://www.batteryfast.co.uk/compaq/f4809a.htm compaq f4809a battery,
    http://www.batteryfast.co.uk/compaq/f4812a.htm compaq f4812a battery,
    http://www.batteryfast.co.uk/dell/inspiron-700m.htm dell inspiron 700m battery,
    http://www.batteryfast.co.uk/dell/inspiron-710m.htm dell inspiron 710m battery,
    http://www.batteryfast.co.uk/dell/latitude-x200.htm dell latitude x200 battery,
    http://www.batteryfast.co.uk/dell/8u443.htm dell 8u443 battery,
    http://www.batteryfast.co.uk/dell/312-0058.htm dell 312-0058 battery,

    Antwoord

Laat 'n antwoord

Jou e-posadres sal nie gepubliseer word nie. Verpligte velde gemerk *