0

I want to get fields list of SPSiteItemCollection that limited by SPQuery view fields. for example I limited the view field which CAML query like this:

spQuery.ViewFields="<FieldRef ='TestFieldName' />";

and I executed query with this code and splist.GetItem(spQuery) passed the result to another function and now I want to get current view fields list in this context I expect to get "TestFieldName" but I don't know how. I know I can find all fields list with codes like this:

List<SPField> fields=listItem.Fields.Cast<SPField>().ToList();

or geting specific view by this code:

List<SPField> fields=list.Views["ViewName"].Fields.Cast<SPField>().ToList();

My question is: how can I get fields list of specific SPQuery view field?

Mehdi
  • 1,731
  • 1
  • 18
  • 33

1 Answers1

0

have you try to use the ViewFieldsOnly ? It should return only the fields specified in the query

spQuery.ViewFields="<FieldRef ='TestFieldName' />";
spQuery.ViewFieldsOnly = true;
Nico
  • 448
  • 4
  • 9