繁体   English   中英

SharePoint CAML查询:值不属于预期范围

[英]SharePoint CAML Query: Value does not fall into expected range

我在一个类中创建了以下方法,该类旨在获取SharePont列表中的所有项目并将其加载到我的实体中:

public List<ItemEntity> FetchItems(SPList list)
{
    // build the CAML query of field names that we wish to retreive
    var query = new SPQuery
        {
            ViewFields = string.Concat("<FieldRef Name='Modified' />",
                                        "<FieldRef Name='Modified By' />",
                                        "<FieldRef Name='Created' />",
                                        "<FieldRef Name='Created By' />")
        };

        SPListItemCollection items = list.GetItems(query);

        return (from SPListItem item in items
                select Load("", // item id
                            "", // content type
                            "", // display name
                            "", // name
                            "", // title
                            "", // url
                            "", // author
                            "", // editor
                            Convert.ToDateTime(item["Modified"]), // date time modified
                            item["Modified By"].ToString(), // modified by
                            Convert.ToDateTime(item["Created"]), // date time created
                            item["Created By"].ToString() // created by
                    )).ToList();
}

由于某种原因,我不明白它会引发以下错误:

值不在预期范围内。

我以为这可能与CAML查询返回的结果有关,但是即使如此,我仍将其限制为元数据字段(我认为每个文件中都应存在该字段),但不幸的是我仍然收到该错误。 我要去哪里错了?

我相信您缺少某些内置字段的正确内部名称。

尝试使用:

item["Author"].ToString() instead of item["Created By"].ToString() and
item["Editor"].ToString() instead of item["Modified By"].ToString()

有关sharepoint 2010内部字段名称的完整参考,我通常参考以下链接: http : //sharepointmalarkey.wordpress.com/2010/10/12/sharepoint-internal-field-names-sharepoint-2010/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM