This project has moved and is read-only. For the latest updates, please go here.

"In" operator

Aug 30, 2011 at 10:40 PM

Have just stumbled upon CAML In operator. Looks like it is missed in Camlex, isn't it?

Meanwhile, it is a very promising one and I believe it would often (but not always, of course) allow to get rid of all this annoying WhereAny and WhereAll with their corresponding foreachs...

What is your input about this?

Aug 31, 2011 at 8:15 PM

Hi omlin,

IN operator is available starting from Sharepoint 2010. If we will introduce it we will lost compatibility with Sharepoint 2007. From other point of view such position prevents evolution of the Camlex. E.g. there is also request about adding of Taxonomy fields support in Camlex. I thought about idea to split releases for 2007 and 2010 versions (fortunately Camlex is on mercurial now and it supports multi branching with merging very well) - e.g. like in WSPBuilder it was done. What do you think about it?

Sep 1, 2011 at 11:47 AM
Edited Sep 1, 2011 at 11:48 AM

Sounds reasonable, such a brilliant project certainly should move forward and aim to inject into the Microsoft.SharePoint namespace :)

Btw, the other new CAML operators in SharePoint 2010 are Includes and NotIncludes. And as I noticed, the Membership is not supported too at the moment, despite of it is available in both 2010 and 2007.

I think that would be a very proper direction of project evolution, to implement all the existing SharePoint features, I mean allow to use them without any workarounds, postreplacing or whatever (rather ugly, to be honest).

By now, unfortunately, despite of rather long period of development, I reckon Camlex.Net still fits mostly very basic needs... :(

Feb 13, 2012 at 4:24 PM
Edited Feb 13, 2012 at 4:28 PM

As release 3.1 still doesn't support these operators I am wondering how I would go about simulating e.g. Includes in Camlex. I've looked through the documentation for SharePoint 2007 and it's not clear if it was even possible to query in a similar way:

Includes from SharePoint 2010 documentation:
If the specified field is a Lookup field that allows multiple values, specifies that the Value element is included in the list item for the field that is specified by the FieldRef element.

Should I inject the <Includes> tag into the output of Camlex (ToCaml)?

Feb 14, 2012 at 10:25 AM

yes these constructions are not in Camlex yet. As workaround you can inject them by linq 2 xml (mentioned ToCaml) or simple string replacing (in the last case add some dummy expression in order to get correct CAML tree with all And and Or, and then replace it with your own). I would also try to use Lookup as string and use string.Contains() method (which is translated to Contains element) - but not sure that it will work.

Jun 15, 2013 at 10:00 PM
Nov 7, 2013 at 12:01 PM
How to make In operator for Taxonomy field ?

For Lookup fields it must contain Lookup="TRUE" definition.

For example: <FieldRef Name="TaxonomyField1" Lookup="TRUE" />
Nov 10, 2013 at 7:49 PM
possibility to add LookupId (as far as I understand you meant LookupId, not Lookup) for IN operation is not implemented yet. It is in the queue (, there were already requests for it. There are 2 workarounds at the moment:
  • add it with string.Replace() on resulting string, which you get from Camlex;
  • use XElement representation of the query (see ToCaml() method) and add attribute via object model.
Dec 9, 2014 at 7:03 PM
Great tool however, I have stumbled upon this issue as well, i.e. a lack of support for includes query.

This is important because without this I am not able to query multi user columns.

However I was able to come up with a work around:

orConditions.Add(x => x["UserField"] > (DataTypes.LookupId) currentUserId);

return CamlexNET.Camlex.Query().WhereAll(expressions).ToCaml(false).FirstOrDefault().ToString(SaveOptions.DisableFormatting).Replace("Gt", "Includes");

Obviously this will not work if you are combining multiple conditions that may include other GT queries.