Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 布尔列的CAML查询不工作_C#_Sharepoint_Caml - Fatal编程技术网

C# 布尔列的CAML查询不工作

C# 布尔列的CAML查询不工作,c#,sharepoint,caml,C#,Sharepoint,Caml,您好,我有一个SharePoint列表要查询我的桌面应用程序,我只想检索活动成员,但当我查询时,我只得到了不活动的用户。我的CAML查询有什么问题 camlQuery.ViewXml = "<<"View">><Query><Where><Eq><FieldRef Name='Active'/><Value Type='Boolean'> " + true + "</Value></Eq>

您好,我有一个SharePoint列表要查询我的桌面应用程序,我只想检索活动成员,但当我查询时,我只得到了不活动的用户。我的CAML查询有什么问题

camlQuery.ViewXml = "<<"View">><Query><Where><Eq><FieldRef Name='Active'/><Value Type='Boolean'> " + true + "</Value></Eq></Where></Query></View>"";
camlQuery.ViewXml=“+true+”;
我也尝试了以下方法

camlQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name='Active'/><Value Type='Boolean'> true</Value></Eq></Where></Query></View>";
camlQuery.ViewXml=“true”;

camlQuery.ViewXml=“true”;

请帮助我,因为我是CAML的新手。

省省一些痛苦,使用工具帮助建立CAML查询,例如

您需要在查询中使用1和0(不是true和false),因此

<Query><Where>
   <Eq><FieldRef Name="Active" /><Value Type="Boolean">1</Value></Eq>
</Where></Query>

1.

使用值类型
Bool
,它可以与“true”、“true”或“true”一起使用

这对我适用

camlQuery.ViewXml = "<View>" + "<Query>" + "<Where>" + "<Eq>" +
"<FieldRef Name='Active'/>" + " <Value Type='Boolean'>" + "1" + "</Value>" +
"</Eq>" + "</Where>" + "</Query>" + "</View>";
camlQuery.ViewXml=”“+“”+“”+
"" + " " + "1" + "" +
"" + "" + "" + "";

尝试在google中搜索,sharepoint中有很多caml查询的示例。您编写的东西看起来不像caml查询。出于某种原因,我不知道,我确信sharepoint有一个bug,因为我有两个布尔列,配置方式相同(列“Returned”和列“Checked”)如果我使用一个CAML代码通过“Returned”列查询spList,它会工作,但是当我将这个CAML代码更改为通过另一列“Checked”查询时,只需将属性名称更改为“Checked”列,其中我们只设置了内部字段名,因此代码不会给我带来任何spListitem,但它应该返回一些项。非常奇怪的列“A”(返回)奇怪的是,对于某些布尔列,您必须将值设置为“true”而不是“1”-我还没有弄清楚为什么要保留Type=“Integer”,您将始终必须使用1和0我认为不存在这样的类型,您能发布显示它的文档链接吗?只需通过Caml查询生成器使用此方法,它就能正常工作!为什么要这样连接查询字符串?@Patric我被教导这样做。
camlQuery.ViewXml = "<View>" + "<Query>" + "<Where>" + "<Eq>" +
"<FieldRef Name='Active'/>" + " <Value Type='Boolean'>" + "1" + "</Value>" +
"</Eq>" + "</Where>" + "</Query>" + "</View>";