I am unable to create a working query with join in my .net csom application. I was using this article:
http://msdn.microsoft.com/en-us/library/ff798388.aspx
here is my code:
ClientContext context = new ClientContext(url);
Web web = context.Web;
var list = web.Lists.GetByTitle("Esemény");
CamlQuery cq = new CamlQuery();
cq.ViewXml= @"<View>
<ViewFields>
<FieldRef Name='Title' />
</ViewFields>
<ProjectedFields>
<Field Name='PartnerLookupTitle' Type='Lookup' List='PartnerLookup' ShowField='Title' />
</ProjectedFields>
<Joins>
<Join Type='LEFT' ListAlias='PartnerLookup'>
<Eq>
<FieldRef Name='Partner' RefType='ID' />
<FieldRef List='Partner' Name='ID' />
</Eq>
</Join>
</Joins>
</View>";
ListItemCollection lista = list.GetItems(cq);
context.Load(lista);
context.ExecuteQuery();
I get an exception from the server: "Value does not fall within the expected range."
If I remove the the ProjectedFields and Joins part of the CAML query it works:(
Ok. I could create a working query:
@"<View>
<ViewFields>
<FieldRef Name='Title' />
<FieldRef Name='Partner'/>
<FieldRef Name='PartnerLookupTitle'/> //new code
</ViewFields>
<ProjectedFields>
<Field Name='PartnerLookupTitle' Type='Lookup' List='PartnerLookup' ShowField='Title' />
</ProjectedFields>
<Joins>
<Join Type='LEFT' ListAlias='PartnerLookup'>
<Eq>
<FieldRef Name='Partner' RefType='ID' />
<FieldRef List='PartnerLookup' Name='ID' />
</Eq>
</Join>
</Joins>
</View>";
Now I can acces the PartnerLookupTitle field, but still dont get this line of code:
<FieldRef List='PartnerLookup' Name='ID' />