పరిష్కారము: 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" ప్రశ్న దృష్టిలో లక్షణం కు.

నా దృష్టాంతంలో:

  • సోమవారం, నేను ఒక పత్రాన్ని అప్లోడ్ మరియు కొన్ని మెటా డేటా సరఫరా.
  • కింది వారం, 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 ముఖభాగం సేవ శోధన చేయాలని ఈ వంటి ఒక ప్రశ్నను ఉపయోగిస్తుంది:

 // ఈ Caml ప్రశ్న ఉత్పత్తి సహాయపడటానికి ఉపయోగించవచ్చు U2U సాధనం.
      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. నిజానికి, ఈ కూడా నా అసలు శోధన సమస్య పరిష్కారమైంది మరియు నేను పునరావృత గుణం మొదటిసారి పేర్కొన్న ఉంటే, నేను మళ్ళీ సమస్య లోకి అమలు కాదు.

వీక్షణకు ఆధారిత SPQuery కొన్ని ఆపరేటర్ల కొరకు పనిచేస్తుంది వాస్తవం (GEQ/LEQ) మరియు ఇతరులు (కలిగి), KPIs ఫోల్డర్ కలిగిన పత్రం గ్రంధాలయాలు అన్ని వద్ద పని కనిపించడం లేదు వాస్తవం తోడైన నాకు ఆ SPQuery కొన్ని ఆర్తోగోనాలిటి సమస్యలు ఉన్నాయి నమ్ముతారు.

ప్రత్యేక ధన్యవాదాలు:

</చివర>

నా బ్లాగ్ సబ్స్క్రయిబ్!

3 "న ఆలోచనలుపరిష్కారము: SPQuery ఫోల్డర్లు శోధించండి లేదు

  1. సంఖ్య పేరు

    http://www.batteryfast.co.uk/asus/w3v.htm ఆసుస్ w3v బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/w3000a.htm asus w3000a battery,
    http://www.batteryfast.co.uk/asus/w3000.htm ఆసుస్ w3000 బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/w3000v.htm ఆసుస్ w3000v బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/a31-s5.htm ఆసుస్ a31-S5 బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/a32-s5.htm ఆసుస్ a32-S5 బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/s52n.htm ఆసుస్ s52n బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/s5000.htm ఆసుస్ s5000 బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/s5200n.htm ఆసుస్ s5200n బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/s5n.htm ఆసుస్ s5n బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/90-naa1b1000.htm ఆసుస్ 90-naa1b1000 బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/s2691061.htm ఆసుస్ s2691061 బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/a42-v6.htm ఆసుస్ a42-V6 బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/a32-u5.htm ఆసుస్ a32-u5 బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/u5f.htm ఆసుస్ u5f బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/u5a.htm ఆసుస్ బ్యాటరీ U5A,
    http://www.batteryfast.co.uk/asus/u5f.htm ఆసుస్ u5f బ్యాటరీ,
    http://www.batteryfast.co.uk/asus/u5.htm ఆసుస్ U5 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/nw8000.htm కాంప్యాక్ nw8000 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/nc8000.htm కాంప్యాక్ nc8000 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/v1000.htm కాంప్యాక్ v1000 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/nc6000.htm కాంప్యాక్ nc6000 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/nx5000.htm కాంప్యాక్ nx5000 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/n600.htm కాంప్యాక్ n600 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/n600c.htm కాంప్యాక్ n600c బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/n610c.htm కాంప్యాక్ n610c బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/n610v.htm కాంప్యాక్ n610v బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/n620c.htm కాంప్యాక్ n620c బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/e500.htm కాంప్యాక్ e500 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/e500s.htm కాంప్యాక్ e500s బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/v300.htm కాంప్యాక్ v300 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/v500.htm కాంప్యాక్ v500 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/pp2060.htm కాంప్యాక్ pp2060 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/nx9000.htm కాంప్యాక్ nx9000 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/nx9005.htm కాంప్యాక్ nx9005 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/nx9010.htm కాంప్యాక్ nx9010 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/nx9020.htm కాంప్యాక్ nx9020 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/n110.htm కాంప్యాక్ n110 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/n110s.htm కాంప్యాక్ n110s బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/pp2101x.htm కాంప్యాక్ pp2101x బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/presario-2100.htm కాంప్యాక్ presario 2100 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/ze4000.htm కాంప్యాక్ ze4000 బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/f4809a.htm కాంప్యాక్ f4809a బ్యాటరీ,
    http://www.batteryfast.co.uk/compaq/f4812a.htm కాంప్యాక్ f4812a బ్యాటరీ,
    http://www.batteryfast.co.uk/dell/inspiron-700m.htm డెల్ ఇన్సిరాన్ 700m బ్యాటరీ,
    http://www.batteryfast.co.uk/dell/inspiron-710m.htm డెల్ ఇన్సిరాన్ 710m బ్యాటరీ,
    http://www.batteryfast.co.uk/dell/latitude-x200.htm డెల్ లాటిట్యూడ్ X200 బ్యాటరీ,
    http://www.batteryfast.co.uk/dell/8u443.htm డెల్ బ్యాటరీ 8u443,
    http://www.batteryfast.co.uk/dell/312-0058.htm చిన్న గుంట 312-0058 బ్యాటరీ,

ఒక Reply వదిలి సంఖ్య పేరు ప్రత్యుత్తరం రద్దు

మీ ఇమెయిల్ చిరునామా ప్రచురితమైన కాదు. లు గుర్తించబడతాయి *