>我正在尝试使用此查询从列表中检索项目:
query.Query =
@"<Where>
<And>
<And>
<Geq>
<FieldRef Name='Date' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(dateFrom) + @"</Value>
</Geq>
<Leq>
<FieldRef Name='Date' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(dateTo) + @"</Value>
</Leq>
</And>
<In>
<FieldRef Name='Employee' LookupId='TRUE' />
<Values>
<Value Type='int'>1</Value>
<Value Type='int'>3</Value>
</Values>
</In>
</And>
</Where>";
在运行时,我得到以下异常:特殊情况感知:一个或多个字段类型未正确安装。转到列表设置页面以删除这些字段在线List.GetItems(query)
.
如果我像这样修改 SPQuery:
query.Query =
@"<Where>
<And>
<Geq>
<FieldRef Name='Date' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(dateFrom) + @"</Value>
</Geq>
<Leq>
<FieldRef Name='Date' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(dateTo) + @"</Value>
</Leq>
</And>
</Where>";
或者这个:
query.Query =
@"<Where>
<In>
<FieldRef Name='Employee' LookupId='TRUE' />
<Values>
<Value Type='int'>1</Value>
<Value Type='int'>3</Value>
</Values>
</In>
</Where>";
一切正常。
令人惊讶的是,问题在于重用SPQuery
对象。所以我创建了一个新SPQuery
一切都很好。