Soluzzjoni: SPQuery Does Mhux Fittex 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" għall-attribut dawl tal-mistoqsija.

Xenarju tiegħi:

  • Nhar it-Tnejn, I ittella 'dokument u jissupplixxi xi metadata.
  • Il-ġimgħa li ġejja, 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").
  • Imxejna ħolqot faċċata servizz web li jipprovdi interface BDC-friendly mal-lista sabiex l-utenti jistgħu faċilment jillokalizza dak id-dokument it-Tnejn permezz ta 'tfittxija titolu.
  • A BDC data column provides a friendly user interface. (Din hija parti mill tentattiv tiegħi fl-użu BDC għal kolonna Lookup aktar faċli).

Il-finali BDC servizz façade juża mistoqsija bħal din tagħmel l-Lookup:

 // Użati għodda U2U biex jgħinu fil-ġenerazzjoni din il-mistoqsija CAML.
      oQuery.Query =
        "<Fejn>";

      jekk (titleFilter.Length > 0)
        oQuery.Query   =
          "  <U>";

      oQuery.Query   =
        "    <U>" +
        "      <Geq>" +
        "        <FieldRef Name=\"DocumentId\" />" +
        "        <Value Type=\"Text\">" + MinID + "</Valur>" +
        "      </Geq>" +
        "      <Leq>" +
        "        <FieldRef Name=\"DocumentId\" />" +
        "        <Value Type=\"Text\">" + maxId + "</Valur>" +
        "      </Leq>" +
        "    </U>";

      jekk (titleFilter.Length > 0)
        oQuery.Query   =
          "    <Fih>" +
          "      <FieldRef Name=\"Title\" />" +
          "      <Value Type=\"Text\">" + titleFilter + "</Valur>" +
          "    </Fih>" +
          "  </U>";
      oQuery.Query   =
        "</Fejn>";

Matul l-istadju inizjali ta 'żvilupp, this worked great. Madankollu, aħna introduċiet folders fil-direttorju biex isolvu xi problemi u f'daqqa waħda, 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, aħna toħloq folder bbażata fuq ID-oġġett lista u mbagħad jimxu l-fajl hemmhekk (I kiteb dwar dan hawn; aħna kellna riżultati mħallta ma dan l-approċċ, iżda fuq kollox, huwa xogħol tajjeb). 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 = ġdid SPQuery();

I minflok jintuża kostruttur dik speċifikata ħsieb:

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

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

Li tissolva l-problema u I bdiet tikseb riżultati tiegħi.

I then added the CONTAINS operator into the mix and it broke again. It turns out that the CONTAINS operator, safejn peux, ma taħdem ma 'l-opinjoni l-istess mod bħall-a GEQ sempliċi / LEQ operators. I did some searching and learned that the query’s ViewAttributes should be set to "Recursive", kif fil-:

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

That solved the problem for CONTAINS. Fil-fatt, dan solvuti wkoll problema tiegħi tfittxija oriġinali u jekk kelli speċifikat l-attribut jirrikorri l-ewwel darba, I ma kien ikun imur lejn il-kwistjoni mill-ġdid.

Il-fatt li SPQuery bbażata view xogħlijiet għal ċerti operaturi (GEQ/LEQ) u mhux oħrajn (FIH), flimkien mal-fatt li KPIs ma jidhirx li jaħdmu fil-livelli kollha mal-libreriji li fihom folder dokument twassalni biex jemmnu li SPQuery għandha xi kwistjonijiet orthogonality.

Grazzi speċjali:

</aħħar>

Abbona għall-blog tiegħi!

3 ħsibijiet dwar "Soluzzjoni: SPQuery Does Mhux Fittex folders

  1. Ebda isem

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

Ħalli Irrispondi

Your email address mhux se jkun ippubblikat. Meħtieġa oqsma huma mmarkati *