Skip to content

Commit 37d4f3d

Browse files
authored
Update upgrade-to-v4.md
1 parent 82d4f5d commit 37d4f3d

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

docs/upgrade-to-v4.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,63 @@ var device = await graphClient.DeviceManagement.ManagedDevices["1"].Request().Ge
126126
Assert.Equal("1",device.Id);
127127
```
128128

129+
### Collection responses do not have @odata.nextLink in the AdditionalData
130+
131+
Response for collection types are now deserialized into the NextLink property in the collection response object(example [here](https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/23e9386538993ebe08ba88c084831b6163304e27/src/Microsoft.Graph/Generated/requests/AccessPackageAssignmentFilterByCurrentUserCollectionResponse.cs#L31)) and are not available in the additionalData bag. The property is then used to automatically initialize the nextPage request for the collection page and can be accessed as below.
132+
133+
```cs
134+
var users = await graphServiceClient.Users.Request().GetAsync();
135+
var nextLink = users.NextPageRequest.GetHttpRequestMessage().RequestUri.OriginalString;
136+
```
137+
138+
#### Note
139+
It is recommended to use the PageIterator when paging through collections as this allows for advance functionality such as configuring pausing, managing state and access to the DeltaLink and NextLink if needed. An example of using the PageIterator with delta is shown below.
140+
141+
```cs
142+
int count = 0;
143+
int pauseAfter = 25;
144+
145+
var messages = await graphClient.Me.Messages
146+
.Request()
147+
.Select(e => new {
148+
e.Sender,
149+
e.Subject
150+
})
151+
.Top(10)
152+
.GetAsync();
153+
154+
var pageIterator = PageIterator<Message>
155+
.CreatePageIterator(
156+
graphClient,
157+
messages,
158+
(m) =>
159+
{
160+
Console.WriteLine(m.Subject);
161+
count++;
162+
// If we've iterated over the limit,
163+
// stop the iteration by returning false
164+
return count < pauseAfter;
165+
}
166+
);
167+
168+
await pageIterator.IterateAsync();
169+
170+
while (pageIterator.State != PagingState.Complete)
171+
{
172+
if (pageIterator.State == PagingState.Delta)
173+
{
174+
string deltaLink = pageIterator.Deltalink;
175+
Console.WriteLine($"Paged through results and found deltaLink : {deltaLink}");
176+
}
177+
178+
Console.WriteLine("Iteration paused for 5 seconds...");
179+
await Task.Delay(5000);
180+
// Reset count
181+
count = 0;
182+
await pageIterator.ResumeAsync();
183+
}
184+
```
185+
129186
## New capabilities
130187

131188
### Azure Identity

0 commit comments

Comments
 (0)