Լուծում: SPQuery չի Որոնել պանակները

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. Ստորին գիծ: assign "recursive" եւ դիտիր հատկանիշի վերաբերյալ հարցումներ.

Իմ սցենարը:

  • Երկուշաբթի, Ես վերբեռնել փաստաթուղթը եւ մատակարարման որոշ meta տվյալներ.
  • Հետեւյալ շաբաթ, 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").
  • Մենք ստեղծել վեբ ծառայության Շինությունների ճակատների, որոնք ապահովում են BDC - ընկերական միջերեսի ցուցակում, որպեսզի օգտվողները կարող են հեշտությամբ տեղադրել այդ Երկուշաբթի փաստաթուղթը միջոցով տիտղոսը որոնել.
  • A BDC data column provides a friendly user interface. (Սա մաս է կազմում իմ փորձ է օգտագործել BDC համար ավելի ընկերական Փնտրել սյունակ).

Վերջնական BDC Ֆասադային ծառայությունը օգտագործում է հարցմանը, ինչպես դա անել Որոնում:

 // Օգտագործված U2U գործիք է աջակցել առաջացնող այս CAML հարցմանը.
      oQuery.Query =
        "<Որտեղ>";

      եթե (titleFilter.Length > 0)
        oQuery.Query   =
          "  <Իսկ>";

      oQuery.Query   =
        "    <Իսկ>" +
        "      <Geq>" +
        "        <FieldRef Name=\"DocumentId\" />" +
        "        <Value Type=\"Text\">" + MinID + "</Արժեք>" +
        "      </Geq>" +
        "      <Leq>" +
        "        <FieldRef Name=\"DocumentId\" />" +
        "        <Value Type=\"Text\">" + maxId + "</Արժեք>" +
        "      </Leq>" +
        "    </Իսկ>";

      եթե (titleFilter.Length > 0)
        oQuery.Query   =
          "    <Պարունակում է>" +
          "      <FieldRef Name=\"Title\" />" +
          "      <Value Type=\"Text\">" + titleFilter + "</Արժեք>" +
          "    </Պարունակում է>" +
          "  </Իսկ>";
      oQuery.Query   =
        "</Որտեղ>";

Ընթացքում նախնական փուլում զարգացման, this worked great. Սակայն, մենք ներկայացրել պանակները մեջ տեղեկագրքի լուծելու որոշ խնդիրներ, եւ հանկարծ, 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, մենք ստեղծել թղթապանակը հիման վրա ID-ի ցանկ Նյութի վերաբերյալ, իսկ հետո տեղափոխել ֆայլը չկա (Ես գրել է այդ մասին այստեղ; մենք ունեինք խառը արդյունքները Այս մոտեցման, բայց ընդհանուր առմամբ, այն աշխատում նաեւ). 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 = նոր SPQuery();

Ես դրա փոխարեն օգտագործվում է մի շինարար է, որ նշված նպատակով:

SPList oList Դուք web.Lists["Documents"];

SPQuery oQuery = նոր SPQuery(oList.Views["All Documents"]);

Այդ լուծել խնդիրը եւ ես սկսեցի ստանալ իմ արդյունքներ.

I then added the CONTAINS operator into the mix and it broke again. It turns out that the CONTAINS operator, այնքանով, որքանով ես կարող եմ ասել, չի աշխատում, ինչպես նաեւ նպատակ է նույն կերպ, ինչպես նաեւ մի պարզ GEQ / LEQ operators. I did some searching and learned that the query’s ViewAttributes should be set to "Recursive", ինչպես:

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

That solved the problem for CONTAINS. Ի դեպ, սա էլ լուծվել իմ օրիգինալ որոնման խնդիրը, եւ եթե ես նշվում է recursive հատկանիշը առաջին անգամ, Ես չէի վազում մեջ է կրկին.

Այն փաստը, որ մի տեսարան հիմնված SPQuery աշխատում, որոշ օպերատորներ (GEQ / LEQ) եւ ոչ թե մյուսները (Պարունակում է), զուգորդված է նրանով, որ KPIs չեն կարծես աշխատել բոլորի հետ, Թղթապանակ պարունակող փաստաթղթերի գրադարանների տանում եմ հավատալ, որ SPQuery ունի որոշ խնդիրներ orthogonality.

Հատուկ շնորհակալություն:

  • Լավ folks է U2U եւ նրանց հարցում գործիք.
  • Michael Hoffer ի մեծ "սովորում են անում" օրագրում Հաղորդագրություն, Դիտողություններն ու պատասխան.

</վերջ>

Անդամագրվել իմ բլոգում!

3 thoughts on "Լուծում: SPQuery չի Որոնել պանակները

  1. No name

    http://www.batteryfast.co.uk/asus/w3v.htm ASUS w3v մարտկոցի,
    http://www.batteryfast.co.uk/asus/w3000a.htm asus w3000a battery,
    http://www.batteryfast.co.uk/asus/w3000.htm ASUS w3000 մարտկոցի,
    http://www.batteryfast.co.uk/asus/w3000v.htm ASUS w3000v մարտկոցի,
    http://www.batteryfast.co.uk/asus/a31-s5.htm ASUS A31-S5 մարտկոցի,
    http://www.batteryfast.co.uk/asus/a32-s5.htm ASUS A32-S5 մարտկոցի,
    http://www.batteryfast.co.uk/asus/s52n.htm ASUS s52n մարտկոցի,
    http://www.batteryfast.co.uk/asus/s5000.htm ASUS s5000 մարտկոցի,
    http://www.batteryfast.co.uk/asus/s5200n.htm ASUS s5200n մարտկոցի,
    http://www.batteryfast.co.uk/asus/s5n.htm ASUS s5n մարտկոցի,
    http://www.batteryfast.co.uk/asus/90-naa1b1000.htm ASUS 90 naa1b1000 մարտկոցի,
    http://www.batteryfast.co.uk/asus/s2691061.htm ASUS s2691061 մարտկոցի,
    http://www.batteryfast.co.uk/asus/a42-v6.htm Asus a42-V6 մարտկոցի,
    http://www.batteryfast.co.uk/asus/a32-u5.htm ASUS A32-u5 մարտկոցի,
    http://www.batteryfast.co.uk/asus/u5f.htm ASUS u5f մարտկոցի,
    http://www.batteryfast.co.uk/asus/u5a.htm ASUS մարտկոցի U5A,
    http://www.batteryfast.co.uk/asus/u5f.htm ASUS u5f մարտկոցի,
    http://www.batteryfast.co.uk/asus/u5.htm ASUS U5 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/nw8000.htm compaq nw8000 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/nc8000.htm Compaq nc8000 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/v1000.htm compaq v1000 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/nc6000.htm Compaq nc6000 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/nx5000.htm Compaq nx5000 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/n600.htm compaq n600 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/n600c.htm compaq n600c մարտկոցի,
    http://www.batteryfast.co.uk/compaq/n610c.htm compaq n610c մարտկոցի,
    http://www.batteryfast.co.uk/compaq/n610v.htm compaq n610v մարտկոցի,
    http://www.batteryfast.co.uk/compaq/n620c.htm compaq n620c մարտկոցի,
    http://www.batteryfast.co.uk/compaq/e500.htm compaq E500 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/e500s.htm compaq e500s մարտկոցի,
    http://www.batteryfast.co.uk/compaq/v300.htm compaq v300 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/v500.htm compaq v500 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/pp2060.htm compaq pp2060 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/nx9000.htm Compaq nx9000 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/nx9005.htm Compaq nx9005 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/nx9010.htm Compaq nx9010 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/nx9020.htm Compaq nx9020 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/n110.htm compaq n110 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/n110s.htm compaq n110s մարտկոցի,
    http://www.batteryfast.co.uk/compaq/pp2101x.htm compaq pp2101x մարտկոցի,
    http://www.batteryfast.co.uk/compaq/presario-2100.htm compaq presario 2100 մարտկոց,
    http://www.batteryfast.co.uk/compaq/ze4000.htm compaq ze4000 մարտկոցի,
    http://www.batteryfast.co.uk/compaq/f4809a.htm compaq f4809a մարտկոցի,
    http://www.batteryfast.co.uk/compaq/f4812a.htm compaq f4812a մարտկոցի,
    http://www.batteryfast.co.uk/dell/inspiron-700m.htm Dell Inspiron 700m մարտկոցի,
    http://www.batteryfast.co.uk/dell/inspiron-710m.htm Dell Inspiron 710m մարտկոցի,
    http://www.batteryfast.co.uk/dell/latitude-x200.htm DELL լայնության x200 մարտկոցի,
    http://www.batteryfast.co.uk/dell/8u443.htm DELL մարտկոցի 8u443,
    http://www.batteryfast.co.uk/dell/312-0058.htm անտառապատ հովիտ 312-0058 մարտկոց,

Թողնել Պատասխանել Paul Galvin Ավելացնել կարծիք Չեղարկել պատասխանել

Ձեր էլ. Փոստի հասցեն չի հրապարակվելու. Պահանջվող դաշտերը նշված են աստղանիշով *