Réiteach: SPQuery Níl an Cuardaigh Fillteáin

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" leis an tréith bhfianaise an cheist.

Mo scéal:

  • Ar Dé Luain, Mé a uaslódáil doiciméad agus roinnt sonraí meta sholáthar.
  • An tseachtain seo a leanas, 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").
  • Cruthaithe againn ar aghaidh seirbhís gréasáin a sholáthraíonn comhéadan BDC-chairdiúil leis an liosta ionas gur féidir le húsáideoirí a aimsiú go héasca an doiciméad Dé Luain trí chuardach teidil.
  • A BDC data column provides a friendly user interface. (Tá sé seo mar chuid de mo iarracht ag baint úsáide as BDC ar feadh colún Lookup níos cairdiúla).

Úsáideann an aghaidh a BDC seirbhís deiridh ar cheist mar seo a dhéanamh ar an lookup:

 // Úsáidte uirlis U2U chun cabhrú ghiniúint an cheist CAML.
      oQuery.Query =
        "<I gcás>";

      más rud é (titleFilter.Length > 0)
        oQuery.Query   =
          "  <Agus>";

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

      más rud é (titleFilter.Length > 0)
        oQuery.Query   =
          "    <Tá>" +
          "      <FieldRef Name=\"Title\" />" +
          "      <Value Type=\"Text\">" + titleFilter + "</Luach>" +
          "    </Tá>" +
          "  </Agus>";
      oQuery.Query   =
        "</I gcás>";

Le linn an gcéad chéim na forbartha, this worked great. Mar sin féin, thugamar isteach fillteáin isteach an t-eolaire a réiteach roinnt fadhbanna agus go tobann, 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 chruthú dúinn fillteán atá bunaithe ar an mír liosta ID agus ansin bogadh an comhad ann (Scríobh mé faoi sin anseo; tá muid go raibh torthaí measctha leis an gcur chuige seo, ach ar an iomlán, tá sé ag obair go maith). 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 = nua SPQuery();

Úsáid mé ina ionad sin Cruthaitheoir atá sonraithe d'fhonn:

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

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

Sin réiteach ar an bhfadhb agus thosaigh mé a fháil ar mo torthaí.

I then added the CONTAINS operator into the mix and it broke again. It turns out that the CONTAINS operator, a mhéid is féidir liom a rá, nach bhfuil ag obair leis an dearcadh ar an mbealach céanna leis an a GEQ níos simplí / LEQ operators. I did some searching and learned that the query’s ViewAttributes should be set to "Recursive", mar atá i:

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

That solved the problem for CONTAINS. Go deimhin, seo a réiteach freisin mo fhadhb cuardaigh bunaidh agus dá mbeadh sonraithe mé an tréith recursive an chéad uair, Ní ba mhaith liom a bheith ar siúl ar an cheist arís.

Ar an bhfíric go n-oibríonn SPQuery dearcadh-bhunaithe le haghaidh roinnt oibreoirí (GEQ/LEQ) agus ní daoine eile (BhFUIL), chomh maith leis an bhfíric nach bhfuil KPI cosúil a bheith ag obair ar chor ar bith le leabharlanna doiciméad fillteán iontu mar thoradh ar dom chun a chreidiúint go bhfuil go SPQuery roinnt saincheisteanna orthogonality.

Go raibh maith agat Speisialta:

  • Na folks maith ag U2U agus a n-uirlis fhiosraithe.
  • Michael Hoffer ar mór "foghlama ag déanamh" blog post, tuairimí agus freagraí.

</deireadh>

Liostáil le mo bhlag!

3 smaointe ar "Réiteach: SPQuery Níl an Cuardaigh Fillteáin

  1. Níl ainm

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

    Freagra

Leave a Reply

Ní thabharfar do sheoladh r-phoist a fhoilsiú. Réimsí riachtanacha atá marcáilte *