If you are a SharePoint developer, and hate having XML/HTML or any other kind of markup/magic string then keep reading. If not, keep reading anyway, you might change your mind ;).

One of these messy things in SharePoint are CAML queries. Since LINQ to SharePoint is far from being reasonably usable, you can’t really avoid them. And they make my code look ugly. So I developed a tool, which can be used to generate CAML queries and statements with C# code.

This is an example of how you would write a simple query using CodeCaml:

query.Query = CQ.Where(CQ.Eq.FieldRef(fieldId).Value(value));

That’s the same as:

query.Query = string.Format("<Where><Eq><FieldRef ID='{0}' /><Value Type='Text'>" + 
                            "{1}</Value></Eq></Where>", fieldId, value);

You can read more on syntax on the project wiki.

Check the source code on github or start using immediately with NuGet.

Disclaimer: The tool is in BETA stage at the moment, so use in production at your own risk. I would also appreciate any feedback.

Comments