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

Taxonomy Field Type in Camlex

Oct 15, 2010 at 7:09 PM

Hi,How can i write following query with Camlex.

Please advise

         <FieldRef Name='AreaDirectory' />
         <Value Type='TaxonomyFieldTypeMulti'>XYZ</Value>

Oct 18, 2010 at 7:25 PM

Hi, ronakce!

Simply speaking - right now you can't.

Camlex project was developed for WSS 3.0 / MOSS 2007, while taxonomies have being adopted only in version SharePoint 2010.

Sure we have a plan to migrate Camlex project to SharePoint 2010 - Camlex 2010, but it will happens only after some time.

Oct 18, 2010 at 7:32 PM


Camlex.NET was developed for Sharepoint 2007 version so currently it has no additional features which came with Sharepoint 2010 (including TaxonomyField). Although it is possible to use Camlex.NET in Sharepoint 2010 - there will no new features available only in 2010 version. We plan support for Sharepoint 2010 in the future. But currently you can use one of the existing extensibility points - ToCaml() method which will return array of XElement[] and you will be able to fix them using linq 2 xml:

// get query as array of XElements
var query = Camlex.Query().Where(x => (string)x["AreaDirectory"] == "XYZ").ToCaml(false);
// fix type manually using linq 2 xml
query[0].Elements().ElementAt(0).Elements().ElementAt(1).SetAttributeValue("Type", "TaxonomyFieldTypeMulti");


As result you will have the following CAML:

    <FieldRef Name="AreaDirectory" />
    <Value Type="TaxonomyFieldTypeMulti">XYZ</Value>

Of course it is not so elegant, but it will work. You can see more about ToCaml() method here.