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
Sharepoint 如何合并SPListItemCollection结果?_Sharepoint - Fatal编程技术网

Sharepoint 如何合并SPListItemCollection结果?

Sharepoint 如何合并SPListItemCollection结果?,sharepoint,Sharepoint,我们正在尝试将每个SPListItemCollection的结果合并到单个SPListItemCollection中 List.GetItems(SPQuery)命令将放置在for…循环中,并将SPListItemCollection作为每个项的输出。每个输出都需要合并并生成singleSPListItemCollection 我一直在使用以下方法迭代SPListItemCollection并将其添加到其他SPListItemCollection中。迭代后,我发现resultset.count始

我们正在尝试将每个SPListItemCollection的结果合并到单个SPListItemCollection中

List.GetItems(SPQuery)命令将放置在for…循环中,并将SPListItemCollection作为每个项的输出。每个输出都需要合并并生成singleSPListItemCollection

我一直在使用以下方法迭代SPListItemCollection并将其添加到其他SPListItemCollection中。迭代后,我发现resultset.count始终为“0”,并且没有附加任何项

设置“SPQuery.ViewFields”后,resultset.count将返回计数,项目将追加到SPListItemCollection中。但是,在设置了“SPQuery.ViewFields”属性之后,下面的方法需要花费更多的时间(对于15000条记录,大约20-30分钟)来附加这些项

如果我没有设置属性,则该方法在迭代中执行得很快,但resultset.count始终为“0”

公共静态SPListItemCollection合并集合(列表集合)
{
SPListItemCollection resultSet=集合[0];
尝试
{
for(int i=1;i
        public static SPListItemCollection MergeCollection(List<SPListItemCollection> collections)
    {
        SPListItemCollection resultSet = collections[0];
        try
        {
            for (int i = 1; i < collections.Count; i++)
            {

                int j = 0;
                foreach (SPListItem listItem in collections[i])
                {

                    SPListItem item = resultSet.Add();
                    foreach (SPField field in collections[i].Fields)
                    {
                        if (field.InternalName != "ID")
                            item[field.InternalName] = listItem[field.InternalName];
                    }
                    j++;
                }

                logging.Add("Result Count {0}", resultset.Count())
            }

        }
        catch (Exception ex)
        {                

        }
        return resultSet;