Does Camlex.NET support with View Fields on the run-time or just as a User Experience?

Jan 17, 2012 at 7:46 AM
Edited Jan 17, 2012 at 7:51 AM

Hi,

Does Camlex.NET support with View Fields on the run-time or just as a User Experience? Does Camlex.NET gets all the view fields in the backend and shows only the ones asked or does it only get only the fields in the select clause on the runtime? This can ideally be checked using datacontext.Logger.

Thanks,
Aseem Sood

Coordinator
Jan 17, 2012 at 8:13 AM
Edited Jan 17, 2012 at 8:39 AM

Aseem,

Camlex is only a tool for generating the CAML. It can't do anything what CAML can't do. So your question is more about CAML. There are 2 properties in the SPQuery class which you should aware:

- SPQuery.ViewFields

- SPQuery.ViewFieldsOnly

when ViewFieldsOnly is set to true, it will return only fields which are specified in ViewFields property. When it is false, it will retrieve values in all fields. ViewFieldsOnly is new property in Sharepoint 2010. In 2007 as far as I remember it worked like ViewFieldsOnly = true. If you need to return also items which do not have values in specified field, you should add Nullable attribute:

 

<FieldRef Name="Foo" Nullable="TRUE" />

 

You can specify SPQuery.ViewFields property using Camlex like this:

 

query.ViewFields = Camlex.Query().ViewFields(x => new[] { x["Foo"], x["Bar"] } );