コード例 #1
0
        public async Task<List<ListItem>> ExecuteQuery(ListQuery query)
        {
            using (var site = CreateSite(query.List.Web.Url))
            {
                using (var web = site.OpenWeb())
                {
                    var serverList = web.Lists.TryGetList(query.List.Title);
                    var listQuery = new SPQuery
                    {
                        Query = query.Query,
                        ViewAttributes = "Scope='RecursiveAll'"
                    };

                    return await Task.Factory.StartNew(() =>
                        serverList.GetItems(listQuery).Cast<SPListItem>()
                            .Select(i => new ListItem(query.List)
                            {
                                Id = i.ID,
                                Columns =
                                    query.List
                                        .Fields
                                        .ToDictionary(
                                            f => f.InternalName,
                                            f => i.GetFormattedValue(f.InternalName))
                            })
                            .ToList()
                    );
                }
            }
        }
コード例 #2
0
        public async Task<List<ListItem>> ExecuteQuery(ListQuery query)
        {
            return await Task.Factory.StartNew(() =>
            {
                System.Threading.Thread.Sleep(2000);

                return new List<ListItem>
                {
                    new ListItem(query.List)
                    {
                        Id = 1,
                        Columns = new Dictionary<string, string>
                        {
                            {Internals.Text, "Test1"},
                            {Internals.User, "Owner1"},
                            {Internals.Date, "Date1"},
                            {Internals.DateTime, "DateTime1"},
                            {Internals.Lookup, "Lookup1"},
                            {Internals.MultiLookup, "MultiLookup1"},
                            {Internals.Integer, "Integer1"},
                            {Internals.Note, "Note1" + Environment.NewLine + "Seccond Line"},
                            {Internals.Url, "Url1"},
                            {Internals.Choice, "Choice1"},
                            {Internals.Boolean, "Boolean1"},
                            {Internals.Readonly, "Readonly1"},
                            {Internals.Hidden, "Hidden1"},
                            {Internals.Number, "Number1"},
                            {Internals.Currency, "Currency1"},
                            {Internals.Computed, "Computed1"},
                            {Internals.MultiChoice, "MultiChoice1"},
                            {Internals.Guid, "Guid1"},
                            {Internals.Calculated, "Calculated1"},
                            {Internals.File, "File1"},
                            {Internals.Attachments, "Attachments1"},
                            {Internals.ContentTypeId, "ContentTypeId1"},
                            {Internals.Geolocation, "Geolocation1"},
                            {Internals.SortTest, "SortTest1"},
                        }
                    },
                    new ListItem(query.List)
                    {
                        Id = 2,
                        Columns = new Dictionary<string, string>
                        {
                            {Internals.Text, "Test2"},
                            {Internals.User, "Owner2"},
                            {Internals.Date, ""},
                            {Internals.Url, null},
                        }
                    },
                    new ListItem(query.List)
                    {
                        Id = 3,
                        Columns = new Dictionary<string, string>
                        {
                            {Internals.Text, "Test3"},
                            {Internals.User, "Owner3"}
                        }
                    },
                };
            });
        }