Mar 8, 2010 at 11:03 PM
Edited Mar 8, 2010 at 11:07 PM
This last is the best approach. Attempting to intuit whether the lookup is by ID vs by title is doomed to be wrong at least sometimes.
A similar issue will arise when dealing with datetimes. There are optional CAML attributes for dateonly versus date+time and local versus UTC. You won't be able to guess correctly which one the developer means.
Overall comment: While your example above of using LINQ to XML to clean up the generated CAML is logically correct, using it means the developer needs to understand CAML, and understand the specific generated CAML in this case well enough to write LINQ code
to pluck out the correct fieldref element, and then correctly insert the CAML amendment.
By the time he/she has done that, it would have been less effort to do what we've all traditionally done: make up a big string & use String.Format(MyCAMLTemplate, param1, param2, param3,...); to populate it at runtime.
In other words, this isn't really a practical solution to working around gaps in CAMLex. It's 100% OK to have gaps & unsupported cases. I'd just suggest that offering LINQ to CAML as a fixup is probably worse than just saying "Sorry,
we don't support that case (yet)."
Overall, this is an awesome tool & I appreciate the thinking & effort going into it.