Gli operatori do comparazione disponibili in una query CAML di SharePoint 2007 sono:
  • Eq = Equals = Uguale
  • Neq = Not equal = Diverso
  • Gt = Greater than = Maggiore di
  • Geq = Greater than or equal = Maggiore o uguale
  • Lt = Lower than = Minore di
  • Leq = Lower than or equal too = Minore o ugale
  • IsNull = Is null = E' nullo
  • BeginsWith = Begins with = Inizia con
  • Contains = Contains = Contiene
mentre gli operatori logici sono
  • And deve soddisfare tutti i criteri
  • Or = deve soddisfare 1 o più criteri
Esempio di query CAML

C#

string str = string.Format(@"
  <Where>
    <And>
      <And>
        <Eq>
          <FieldRef Name=""Location"" LookupId=""True"" />
          <Value Type=""Lookup"">{0}</Value>
        </Eq>
        <Leq>
          <FieldRef Name=""EventDate"" />
          <Value IncludeTimeValue=""TRUE"" Type=""DateTime"">{1}</Value>
        </Leq>
      </And>
      <Geq>
        <FieldRef Name=""EndDate"" />
        <Value IncludeTimeValue=""TRUE"" Type=""DateTime"">{1}</Value>
      </Geq>
    </And>
  </Where>
", id, SPUtility.CreateISO8601DateTimeFromSystemDateTime(now.ToUniversalTime()));
La stessa sintassi è utilizzata per creare una query nellìoggetto SPQuery.
Tags:
CAML17 SharePoint497 SharePoint 2007218 SharePoint 2010224
Potrebbe interessarti anche: