[英]SharePoint CSOM query return every field null
I want to retrive some fields with CAML Query - everytime when i execute query for example:我想用 CAML 查询检索一些字段 - 每次我执行查询时,例如:
query.ViewXml = string.Format(@"
<View>
<Query>
<Where>
<Eq>
<FieldRef Name='IDCardNumber' LookupId='TRUE'/>
<Value Type='Text'>12345</Value>
</Eq>
</Where>
</Query>
</View>
< ViewFields >
< FieldRef Name = 'Title' />
</ ViewFields >)");
var items = list.GetItems(query);
clientContext.Load(items);
clientContext.ExecuteQuery();
Query returns 0 elements.查询返回 0 个元素。
I tried to get all elements and with CamlQuery.CreateAllItemsQuery();
我试图获取所有元素并使用
CamlQuery.CreateAllItemsQuery();
- and in date I see correct count in list data, but FieldValues in elements look like this: Screenshot from VS Locals - 在日期中我看到列表数据中的正确计数,但元素中的 FieldValues 看起来像这样:来自 VS Locals 的截图
In CAML Query Builder Tool:在 CAML 查询生成器工具中:
<Where>
<IsNotNull>
<FieldRef Name='Title' />
</IsNotNull>
</Where>
</Query>
Returns: Screenshot from CAML Query Builder返回:来自 CAML 查询生成器的屏幕截图
How to get these values correctly?如何正确获取这些值?
I think the value type should be "Lookup" then your using the id of the lookup field (ie the id of the field in the alternative list)我认为值类型应该是“Lookup”然后你使用查找字段的id(即替代列表中字段的id)
<Eq>
<FieldRef Name='IDCardNumber' LookupId='TRUE'/>
<Value Type='Lookup'>12345</Value>
</Eq>
ViewFields goes in View ViewFields 进入视图
query.ViewXml = @"<View>
<Query>
<Where>
<Eq>
<FieldRef Name='IDCardNumber' LookupId='TRUE'/>
<Value Type='Lookup'>12345</Value>
</Eq>
</Where>
</Query>
<ViewFields>
<FieldRef Name = 'Title'/>
<FieldRef Name = 'IDCardNumber'/>
</ViewFields>
</View>
";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.