Workflow, Collaboration, Enterprise Content Management

Generate CAML.NET Queries using T-SQL Syntax

by John Holliday 4. October 2007 16:51

Boy, news travels fast on the Internet!  Awhile back, my fellow SharePoint MVP Carlos Segura Sanz came up with a pretty nifty tool that lets you create CAML queries using T-SQL syntax.  It's called YACAMLQT for "Yet Another CAML Query Tool", and you can read all about it here

Basically, it lets you write a query like this:

WHERE ContentType="My Content Type"
OR Description<>null
GROUPBY Title DESC
ORDERBY _Author, AuthoringDate, AssignedTo ASC

YACAMLQT then parses the text and produces a CAML query that looks like this:

YACAMLQT to CAML

Pretty cool, eh?

So I got to thinking, "Why not extend the tool to generate CAML.NET code?".  Then you would have the convenience of T-SQL with the power and extensibility of C#.

Well, wouldn't you know it?  Carlos was already way ahead of me.  In fact, he had already implemented it.  Here is a screenshot of the latest version of YACAMLQT, that now has an extra tab containing the generated CAML.NET code!

YACAMLQT to CAML.NET

I'm working with Carlos to extend his tool to support some additional feature, like adding a SELECT clause so you can easily specify the view fields.  I'm also looking at ways to incorporate the YACAMLQT parser directly into the CAML.NET framework so you could do things like pass a T-SQL string to an existing CamlQuery instance to take advantage of the built-in data binding features of CAML.NET.

Look for updates to appear soon on both our blogs, and also on the CAML.NET Project on CodePlex.  In the meantime, you can download the updated YACAMLQT tool from the following link:

 YACAMLQT.zip (15,07 KB).

Technorati tags: , , ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

CAML | Code Generation | SharePoint Development

Comments

10/5/2007 12:51:53 PM

Rich Liang

If you can, please respond by Email.

Hopefully, you are the John Holliday that wrote the script, "logoffin30".

If you are not, thank you for your time and have a nice day.

If you are, I have a question or two. This script found its way into my startup folder, even though I have never seen nor heard of it before. Is it possible that the script is bundled with software of any type? I'm not sure how the script got on the computer, it doesn't seem malicious in any way, and therefore would rule out a virus. It's possible that someone put it on the computer as a practical joke, but I also find that unlikely. Would you know of any ways this script could have entered the folder?

Rich Liang

10/5/2007 1:49:59 PM

John Holliday

Sorry, Rich - must be a different John Holliday. I've never heard of the script you mention. Good luck getting rid of it.

John Holliday

11/13/2007 11:33:34 AM

Tyler Durham

This script seems to be used by system administrators to "log off" users after a period of inactivity -- are you using a work computer? This file may have been deployed via SMS or Group Policy... I would remove it and see if it re-appears.

It also appears to have been written by a John Holliday in Germany, not this John Holliday.

More info here: www.petri.co.il/forums/showthread.php?t=6142

Tyler Durham

6/23/2008 9:24:54 PM

B.s. van veen

Is it also possible to use the api to parse to otherway around. So from CAML to Sql Where

B.s. van veen

6/26/2008 6:16:17 AM

John Holliday

First of all, I'm not sure what you would do with the generated SQL. Are you thinking of executing SQL queries directly against the content DB? That's not a good idea under any circumstances.

John Holliday

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Copyright © 2005-2008, John F. Holliday
This work is licensed under a Creative Commons License Powered by BlogEngine.NET 1.4.0.0

About Me

John Holliday

Independent author, consultant, trainer, and software developer specializing in enterprise content management, collaboration, workflow and business process automation. SharePoint training for developers and administrators

 

Recent comments

Comment RSS