How about creating the SPQuery object using the constructor where you can pass the appropriate SPView.
You could then add a query to include the appropriate items, something like:-
var query = new SPQuery(spView);
query.Query = String.Format("<Where><Eq><...
This really intrigued me so I invested an hour into analysis of the problem.
First of all, I was able to show the view using unchanged OP's declarative description of the view:
Unfortunately, to achieve this I had to change internal state of variables inside Microsoft.Sharepoint.dll. Conclusion, you can't do this without recompiling SharePoint or injecting ...
The aggregation is not something that is calculated and stored but just defined type of aggregation required or to be done.
You need to calculate it your own. SharePoint displays the aggregated data by using XSLT.
I was looking for an answer to this today. It appears to work if the type is in capitals.
<FieldRef Name="LinkFilename" Type="COUNT" />
<FieldRef Name="LinkFilename" Type="Count" />
Try to use one of the tokens
I faced with problem that JSLink does not work without them.
In some cases you should encode "~" symbol.
When you add a new field i.e. Field2 it will automatically get added at the last of the view field collection. In order to place it at a proper place you will first need to create collection of fields based on their order, then clear all the fields in the view collection and finally adding the fields from your ordered collection to the view.
This may be ...