SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if CAML query Value Types are strongly typed or not. It would save me some time if I didn't have to specify "text" or "date" every time I made a query.

Here is the code I am using, its part of a helper method that allows me to grab an item based on a certain field and that field's value.

String camlQuery = "<Where><Eq><FieldRef Name ='" + internalFieldName + "' /><Value Type='" + fieldType + "'>" + fieldValue + "</Value></Eq></Where>

I would like to get rid of the if possible.

share|improve this question

You don't necessarily do but it is highly recomanded to do so when you know them (particularly for Lookup, User, Data) while filtering. Pasted more examples below for your reference.

      <ProjectProperty Name="Title"      Nullable="TRUE" />
      <ProjectProperty Name="Url"        Nullable="TRUE" />
      <FieldRef Name="EncodedAbsUrl"     Nullable="TRUE" />
      <FieldRef Name="PublishingContact" Nullable="TRUE" />
      <FieldRef Name="Title"                             />
      <FieldRef Name="FileRef"                           />
      <FieldRef Name="Comments"                          />
      <FieldRef Name="ID"                                />
      <FieldRef Name="Modified"                          />
      <FieldRef Name="Created"                           />
      <FieldRef Name="PublishingRollupImage"             />
      <FieldRef Name="Author"                            />
      <FieldRef Name="Editor"                            />
                  <FieldRef Name="ContentTypeId" />
                  <Value Type="Text">0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39001bb192640f8748d78db60217bd43598900f8c9db8d7f634c95bfd7ee95032f71c2</Value>
                  <FieldRef Name="ContentTypeId" />
                  <Value Type="Text">0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39001bb192640f8748d78db60217bd435989004896ce0317db45a9ae9e840754b48672</Value>
               <FieldRef Name="_ModerationStatus" />
               <Value Type="ModStat">Approved</Value>
         <FieldRef Name="Modified" Ascending="FALSE" />
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.