我正在尝试对共享点列表(使用客户端对象模型)运行查询,找到与日期字段匹配的项目。
我的查询是:2012-07-24T02:50:28 1
我知道列表中有一个项目 EmDateSent 字段的值为 2012-07-24T02:50:28 ,但是当我运行它时,我得到了 0 行。
经过数小时的研究和试验,我发现我使用的日期格式有效——至少我是这么认为的。现在好像不行了。
我的代码如下。
任何人都可以建议我可以尝试的其他东西吗?
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = String.Format(
@"<View>
<Query>
<Where>
<Eq>
<FieldRef Name='{0}'/>
<Value Type='DateTime' IncludeTimeValue='True'>{1}</Value>
</Eq>
</Where>
</Query>
</View>", EMAIL_FIELD_DATE_SENT, details.DateSent.HasValue ? details.DateSent.Value.ToString("yyyy-MM-ddTHH:mm:ss") : "");
ListItemCollection listItems = upLoadList.GetItems(camlQuery);
_context.Load(listItems);
_context.ExecuteQuery();
if (listItems.Count > 0) // At this point I expect listItems.Count to be 1, but it is 0
{
....